igli 1205756912 learn [[ -d $foo ]] || { echo 'ohNoes!' >&2; exit 1; } koala_man 1276606187 forget koala_man 1276606189 learn foo || bar runs bar when foo fails: [[ -d $foo ]] || { echo 'ohNoes!' >&2; exit 1; } lhunath 1372353217 forget lhunath 1372353219 learn Conditional Operators && and ||: foo || bar && quux - When a command succeeds, the command after the first && following it will be executed. When it fails, the first ||. Eg. [[ -e $file ]] || { echo >&2 "File not found: $file"; exit 1; } # See http://mywiki.wooledge.org/BashSheet#Tests lhunath 1372353302 forget lhunath 1372353306 learn Conditional Operators: foo || bar && quux - When a command succeeds, the command after the first && following it will be executed (if foo succeeds, run quux). When it fails, the first ||. Eg. [[ -e $file ]] || { echo >&2 "File not found: $file"; exit 1; } # See http://mywiki.wooledge.org/BashSheet#Tests lhunath 1372353481 forget lhunath 1372353490 learn Conditional Operators: foo || bar && quux - When a command succeeds, the command after the first && following it will be executed (if foo or bar succeed, run quux). When it fails, the first ||. Eg. [[ -e $file ]] || { echo >&2 "File not found: $file"; exit 1; } # See http://mywiki.wooledge.org/BashSheet#Tests lhunath 1372353570 forget lhunath 1372353572 learn Conditional Operators: foo || bar && quux - When a command succeeds, the command after the next && will be executed (if foo or bar succeed, run quux). When it fails, the next ||. Eg. [[ -e $file ]] || { echo >&2 "File not found: $file"; exit 1; } # See http://mywiki.wooledge.org/BashSheet#Tests lhunath 1391096634 forget lhunath 1391096646 learn Control Operators: foo || bar && quux - When a command succeeds, the command after the next && will be executed (if foo or bar succeed, run quux). When it fails, the next ||. Eg. [[ -e $file ]] || { echo >&2 "File not found: $file"; exit 1; } # See http://mywiki.wooledge.org/BashSheet#Tests greycat 1408035665 forget greycat 1408035667 learn Short-circuit control operators A || B means "Run A. If A fails, run B." A && B means "Run A. If A succeeds, run B." Example: foobar || { echo "error" >&2; exit 1; }