引用了上一个命令的输出

cou*_*que 1 command-line 11.10

假设您处于以下情况:

<command 1>
<output of command 1>
<want to use output of command 1 here without have to retype it>
Run Code Online (Sandbox Code Playgroud)

我的具体情况:

which eclipse
/usr/bin/eclipse
ldd /usr/bin/eclipe
Run Code Online (Sandbox Code Playgroud)

但我宁愿不必输入最后一行,有什么捷径吗?

Flo*_*sch 6

使用$()

ldd "$(which eclipse)"
Run Code Online (Sandbox Code Playgroud)

  • @Blair:`$()` 比反引号更受欢迎,因为它是可嵌套的。因此,养成使用 `$()` 的习惯是件好事,即使它们不是绝对必要的。 (2认同)