Using output of previous commands in bash

后端 未结 5 2130
情书的邮戳
情书的邮戳 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条回答
  •  萌比男神i
    2021-02-20 01:09

    You could do this:

    make
    !! | grep "warning"
    

    By using !! you tell it to repeat the last command in that spot, along with any other bash commands you want to add to it.

    The downside is that if the command you are repeating takes a long time to execute, you'll have that much longer to wait unless you stored the output of the previous command to an output file first.

提交回复
热议问题