What Do Douple Pipes Do?


Recommended Posts

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 so

do_something || handle_error

The 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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...