- The command
test allows two strings or two integers to
A shorthand version uses
around the arguments.
WARNING: be very careful to put the spaces in correctly!
The syntax is very different for comparing numbers or strings (see
help test for the syntax options).
test can also be used to check the status of files (whether they exist, are writable, etc.)
test $a = my
| string equality|
[ $a = my ]
| as above|
[ $a -eq 2 ]
| tests numerical equality|
[ 11 -gt 2 ]
| compares numbers (greater than)|
[ 11 > 2 ]
| does NOT do numerical comparison|
[ -e im1.nii.gnii.gz ]
| tests if file exists|
| || |
Note: for non-integer numerical comparisons, see |