Browse
Advanced Bash-Scripting Guide (downloadable as a pdf,...). One common error is forgetting to put a space after (resp. before) the [ (resp. ]). You also got one liners like
- Code: Select all
[ 1 = 1 ] && echo "1 = 1"
[ 1 = 1 ] || echo "what? 1 != 1"
which are equivalent to "if ... statement", "iunless ... statement".
Note: a test in bash is just the return value of a program/builtin, with the convention 0=true. In bash [ ... ] is a builtin. But other shells (sh?) use /usr/bin/[ which is a link to /usr/bin/test.