Pipe | Redirection < > Precedence

前端 未结 5 2022
清酒与你
清酒与你 2020-12-13 05:07

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

5条回答
  •  天涯浪人
    2020-12-13 05:34

    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.

提交回复
热议问题