Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Is there any equivalent in Fish?

share|improve this question

1 Answer 1

up vote 24 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.