How does AND and OR operators work in Bash?

From man bash

3.2.3 Lists of Commands

A list is a sequence of one or more pipelines separated by one of the operators ‘;’, ‘&’, ‘&&’, or ‘||’, and optionally terminated by one of ‘;’, ‘&’, or a newline.

Of these list operators, ‘&&’ and ‘||’ have equal precedence, followed by ‘;’ and ‘&’, which have equal precedence.

So, your example

echo this || echo that && echo other

could be read like

(this || that) && other

Leave a Comment