test-evaluates an expression

 <  Day Day Up  >  

test ” evaluates an expression

test evaluates an expression and returns an exit status indicating that the expression is either true (0) or false (not zero). Used primarily by Bourne and Korn shell for string, numeric, and file testing. The C shell has most of the tests built-in.

Example A.60.
 1   test 5 gt 6 2   echo $? ( Bourne and Korn shells)    (Output is 1, meaning the result of the test is not true.) 

EXPLANATION

  1. The test command performs an integer test to see if 5 is greater than 6 .

  2. The $? variable contains the exit status of the last command. If a nonzero status is reported , the test results are not true; if the return status is 0, the the test result is true.

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net