cd ~/it244/ex
mkdir ex22
cd ex22
test with Numberstest with the -eq (equality for numbers) operator
test 4 -eq 5; echo $?
Since anything other than 0 as an exit status signals failure,
this means that the equality test has failed.
test 4 -eq 4; echo $?
Since 0 means success, this means that the expression evaluated to true.
test with the -ne (not equal for numbers) operator
test 4 -ne 5; echo $?
0 means true.
test 4 -ne 4; echo $?
1 means false.
test with the -gt (greater than) operator
test 4 -gt 5 ; echo $?
test 5 -gt 4 ; echo $?
test 5 -ge 4 ; echo $?
test 5 -ge 5 ; echo $?
test 4 -lt 5 ; echo $?
test 5 -lt 4 ; echo $?
test 4 -le 5 ; echo $?
test 4 -le 4 ; echo $?
test with String Comparison Operatorstest with the = (string equality) comparison operator
test foo = foo ; echo $?
test foo = bar ; echo $?
test with the != (string not equal) comparison operator
test foo != bar ; echo $?
test foo != foo ; echo $?
test with Single String Operatorstest with the -n (length greater than 0) string operator
test -n foo ; echo $?
test -n "" ; echo $?
test with the -z (length is 0) string operator
test -z "" ; echo $?
test -z foo ; echo $?
cd ~/it244/ex/ex22
chmod 755 arg_test.sh
./arg_test.sh
./arg_test.sh foo
./arg_test.sh foo bar
./arg_test.sh foo bar bletch
~tsoro/it244_test/ex22.sh
When the script asks if you are ready for more, hit Return or Enter.