next up previous contents
Next: Testing/Comparing Numbers Up: Programming the Shell Previous: read: Reading Input from

test: Comparisons

A common requirement of many programs is to compare two, three, or more things together. Strings and numbers may be compared. Files are often checked for their lengths and/or existence.

All such verifications are done using variants of the test command.

The general usage of test is

test expression

If expression is true, a return code of 0 is supplied.

If expression is false, a non-zero return code is generated.





Claude Cantin
Sun Sep 1 02:02:26 EDT 2002