OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

test

By far, the command used most frequently with if is test. The test command per- forms a variety of checks and comparisons. It has two equivalent forms:

test expression and the more popular: [ expression ]

where expression is an expression that is evaluated as either true or false. The test com- mand returns an exit status of zero when the expression is true and a status of one when the expression is false.

It is interesting to note that both test and [ are actually commands. In bash they are builtins, but they also exist as programs in /usr/bin for use with other shells. The ex- pression is actually just its arguments with the [ command requiring that the “]” charac- ter be provided as its final argument.

The test and [ commands support a wide range of useful expressions and tests.


 

Top OS Cloud Computing at OnWorks: