巴什 - 从最后一个命令的输出重用 [英] Bash - Reusing output from last command

查看:80
本文介绍了巴什 - 从最后一个命令的输出重用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是存储在任何寄存器bash命令的输出?例如。类似的东西 $?捕获它的输出,而不是退出状态。

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 output to a variable with:

output=$(command)

不过这更多的输入...

but that's more typing...

推荐答案

您可以使用此: $(!!)
重用(重新计算,如memecs precised)的最后一个命令的输出。

You can use this: $(!!) to reuse (recompute, as memecs precised) 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

这篇关于巴什 - 从最后一个命令的输出重用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆