How can you diff two pipelines in Bash?

前端 未结 3 1071
甜味超标
甜味超标 2020-12-02 04:29

How can you diff two pipelines without using temporary files in Bash? Say you have two command pipelines:

foo | bar
baz | quux

And you wan

3条回答
  •  忘掉有多难
    2020-12-02 05:00

    In bash you can use subshells, to execute the command pipelines individually, by enclosing the pipeline within parenthesis. You can then prefix these with < to create anonymous named pipes which you can then pass to diff.

    For example:

    diff <(foo | bar) <(baz | quux)
    

    The anonymous named pipes are managed by bash so they are created and destroyed automatically (unlike temporary files).

提交回复
热议问题