This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| sysadminery:bash [2025/05/06 15:32] – adam | sysadminery:bash [2025/11/08 08:05] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 43: | Line 43: | ||
| you can use named capture groups, but you have to do '' | you can use named capture groups, but you have to do '' | ||
| + | |||
| + | === achieve transcendant enlightenment === | ||
| + | |||
| + | <code bash> | ||
| + | curl arg.rip/ | ||
| + | </ | ||
| + | |||
| + | "wow, that was perfect for me, now all of my problems have been solved forever" | ||
| + | |||
| + | === what is going on with my variables === | ||
| + | |||
| + | watch this. | ||
| + | <code bash> | ||
| + | echo "# phase 5: blah blah blah" | ||
| + | |||
| + | goodreads=0 | ||
| + | badreads=0 | ||
| + | |||
| + | find " | ||
| + | do | ||
| + | |||
| + | n=$(grep -Poh " | ||
| + | w=$(grep -Poh " | ||
| + | |||
| + | if [ -n " | ||
| + | goodreads=$(($goodreads+1)) | ||
| + | echo " | ||
| + | else | ||
| + | badreads=$(($badreads+1)) | ||
| + | echo " | ||
| + | fi | ||
| + | done | ||
| + | |||
| + | echo " | ||
| + | </ | ||
| + | |||
| + | it resets them to 0 after the loop. This is because bash uses dyanmic scope. https:// | ||
| + | |||
| + | so how do we force bash to operate correctly, with lexical scope? according to the internet, you use `local`. doesn' | ||
| + | once you do that, the subscope doesn' | ||