shanenin Posted June 6, 2005 Report Share Posted June 6, 2005 I see some bash scripts with double pipes, || , what do they do? Quote Link to post Share on other sites
jcl Posted June 6, 2005 Report Share Posted June 6, 2005 Logical OR. A || B is true if either A or B is true. The shell 'short-circuits' the conditional, so B is only evaluated when A is false, making it a useful control structure. For example, if you have some expression that can potentially fail, you can use || to add simple error-handling code like sodo_something || handle_errorThe right-hand side will only be executed if the left-hand side fails.The shell also provides the logical AND operator '&&' and NOT operator '!'. A && B is true iff both A and B are true, and short-circuits so that B is evaluated only if A is true. Useful for sequencing commands. NOT acts as an inverter: ! A is true when A is false and vice versa. Quote Link to post Share on other sites
shanenin Posted June 6, 2005 Author Report Share Posted June 6, 2005 those could come in handy. Thanks :-) Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.