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

Is there any equivalent in Fish?


2 Answers 2


The logical operators you're used to, are supported since fish 3.0.0, released on 2018-12-28.

From the v3 release notes:

  • fish now supports && (like and), || (like or), and ! (like not), for better migration from POSIX-compliant shells (#4620).

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:

and command2
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

  • 4
    There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell
    – aboy021
    Feb 26, 2016 at 0:41
  • 23
    This allows using a more familiar syntax: is very subjective Jun 2, 2016 at 10:46
  • 1
    ;and is less readable than && as the semicolon suggests a logically disjoint operation. It's visually jarring. Jul 30, 2017 at 20:08
  • @Elliott I agree, but Fish doesn't give you a choice.
    – Dennis
    Jul 30, 2017 at 20:11
  • 2
    do note though that in fish and bourne shells, AND and OR operators have the same order, unlike C based languages: unix.stackexchange.com/a/88851/50703
    – balupton
    Jan 11, 2018 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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