next up previous contents
Next: set: Change Command-line Parameters Up: Miscellaneous Previous: A || B: Either

A && B: A or Both

A and B each represent a distinct set of commands. If the return code from set A is 0 (successful), set B will be executed. Otherwise, set B will not be executed.

For example,

#!/bin/sh
FILE="/usr/tmp/junk"
test -f $FILE  && rm $FILE
first verifies that the file exists, then erases it. If it did not exist, the rm command would not have been issued.

A series of commands could have been executed, as shown in the previous ``||" example.



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