Precedence of shell operator Precedence of shell operator shell shell

Precedence of shell operator


  1. Redirections (<, >, >>, <>, <&. >& and >>-, as well as here-docs <<delimiter and here-strings <<<word) are roughly the same as command-line arguments, and can appear anywhere in a simple command, including before the command word. Effectively, they bind most tightly, as with postfix operators in most languages.
  2. Pipes (|) are the strongest binary operator. They associate to the left.
  3. Finally come the short-circuiting booleans (&& and ||). Unlike many languages, these have the same precedence. They also associate to the left.

, is not a bash operator. ; and & are statement terminators, not separators, although in some circumstances the final separator is optional. Effectively, they have the lowest precedence.

See the shell grammar for details. There are lots of details.