I want to make clear when does pipe | or redirection < > takes precedence in a command?
This is my thought but need confirmation this is how it works.
Exa
It's a little unorthodox, but perfectly legal, to place the <
anywhere you like, so I prefer this as it better illustrates the left-to-right data flow:
output.txt
The only time you cannot do this is with built-in control structure commands (for
, if
, while
).
# Unfortunately, NOT LEGAL
Note that all of these are equivalent commands, but to avoid confusion you should use only the first or the last one:
Because the file name must always come directly after the redirection operator, I prefer to leave out the optional space between the <
and the file name.