bash testing variables for negative numbers or values

From thelinuxwiki
Revision as of 21:55, 10 July 2014 by Nighthawk (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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