next up previous contents
Next: A && B: A Up: Miscellaneous Previous: $?: Return Code

A || B: Either or

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

If the return code from set A is non-zero (unsuccessful), then set B will be executed.

For example,

#!/bin/sh
FILE="/usr/tmp/junk"
test -f $FILE || {
    echo "File $FILE does not exist."  
    echo "Let's create it."
    touch $FILE
}



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