Using output of previous commands in bash

后端 未结 5 2056
情书的邮戳
情书的邮戳 2021-02-20 00:50

In Mathematica, it is possible to reuse the output of the previous command by using %.

Is something similar possible for bash (or some other shell)?

For example,

5条回答
  •  Happy的楠姐
    2021-02-20 01:21

    If you use tee to duplicate the output stream to /dev/stderr, there's no need for a temp file; plus, after that, you can filter the stdout stream with sed to create a make_warning.log file - all in one line of Unix shell pipes.

    make 2>&1 | tee /dev/stderr | \
       sed -E -n 's/(.*[Ww][Aa][Rr][Nn][Ii][Nn][Gg].*)/\1/p' > make_warning.log
    

提交回复
热议问题