# Looping per line of input some | command | sequence | while read var1 var2; do # something here done # Reading a file line by line while read var1 var2 etc; do perform --commands --with $var1 $var2 $etc done < some-file.ext # The for loop with test syntax for f in *; do if [[ -d "$f" ]]; then pushd "$f"; echo "Do work"; popd; fi; done # Test for a pattern match [[ $some-var =~ ^(some|regex)$ ]] && echo "Yep, it's a match!" # Process substitution: http://tldp.org/LDP/abs/html/process-sub.html cat <(what magic is this?) # Load an array with data # http://unix.stackexchange.com/questions/99423/appending-to-same-array-in-various-loops-only-last-values-remain-bash-4 some_array=() while some test; do some_array+=("$some_variable") done < <(some command producing output) # if __name__ == '__main__': equivalent if [[ ${BASH_SOURCE[0]} != $0 ]]; then # We were sourced, not run else # We are being run, go, go, go! fi