re: Bash from scratch: learn enough bash to write your own scripts VIEW POST

FULL DISCUSSION
 

Instead of referring to some online articles on test conditions, you can just check out man test.

Conditions and most other such things are good to shorthand a bit, and if you're planning on using BASH use [[ ... ]] instead of [ ... ] as they also function differently. Stick to one style for predictability. serverfault.com/a/52050

Slightly compacted formats

if [[ "$FOO" == "1" ]]; then
  ...
else
  ...
fi

for i in 1 2 3 4; do
  echo $i
done

while [[ true ]]; do
  ...
done

Also shellcheck.net/ is an excellent resource to use to check your scripts for common bugs etc. There's even a decent unit testing framework for BASH scripts nowadays: github.com/sstephenson/bats

 

This is fantastic! Iā€™m still new to bash scripting :) but will include this in the article. Great feedback!!

 

I have updated the post, thank you again for the feedback!

code of conduct - report abuse