Reusing output from last command in Bash

后端 未结 13 2055
长情又很酷
长情又很酷 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:55

    You can use $(!!) to recompute (not re-use) the output of the last command.

    The !! on its own executes the last command.

    $ echo pierre
    pierre
    $ echo my name is $(!!)
    echo my name is $(echo pierre)
    my name is pierre
    

提交回复
热议问题