Reusing output from last command in Bash

后端 未结 13 2054
长情又很酷
长情又很酷 2020-12-07 08:35

Is the output of a Bash command stored in any register? E.g. something similar to $? capturing the output instead of the exit status.

I could assign the

13条回答
  •  攒了一身酷
    2020-12-07 08:40

    You can use -exec to run a command on the output of a command. So it will be a reuse of the output as an example given with a find command below:

    find . -name anything.out -exec rm {} \;
    

    you are saying here -> find a file called anything.out in the current folder, if found, remove it. If it is not found, the remaining after -exec will be skipped.

提交回复
热议问题