Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Bash/ZSH and other shells, I am used to using && and ||.

Is there any equivalent in Fish?

share|improve this question
up vote 64 down vote accepted

Fish doesn't have a special syntax for a logical AND (&&) or a logical OR (||).

Instead, you can use the commands and and or, which verify the previous command's exit status and act accordingly:

command1
and command2
command1
or command2

Furthermore – just like in bash – you can use a semicolon ; to execute two commands one after the other:

command1 ; command2

This allows using a more familiar syntax:

command1 ;and command2
command1 ;or command2

See http://fishshell.com/docs/current/tutorial.html#tut_combiners

share|improve this answer
2  
There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell – aboy021 Feb 26 at 0:41
5  
This allows using a more familiar syntax: is very subjective – Petr Peller Jun 2 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .