bash testing variables for negative numbers or values

From thelinuxwiki
Jump to: navigation, search

use test then check its exit value ($? = exit value of the previous command)

$ test -4 -lt 0; echo $?;
0
$ test 4 -lt 0; echo $?;
1