<tt>A && B</tt>: Both or Nothing



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

A && B: Both or Nothing

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.



Super-User
Fri Feb 17 15:55:40 EST 1995