鱼壳命令替换

时间:2014-03-20 15:31:01

标签: bash shell terminal fish

有没有更好的方法在鱼壳中进行命令替换?

在bash中,我可以这样做:

~> echo $(whoami) => user
~> echo "I am: $(whoami)" = > I am: user

但在鱼类中看起来像我必须做的事情:

~> echo (whoami) => user
~> echo "I am: (whoami)" => "I am: (whoami)"
~> set who (whoami); echo "I am: $who" => I am: user

这是在fish中进行命令替换的推荐方法,其中替换需要在带引号的字符串中发生吗?

1 个答案:

答案 0 :(得分:11)

你可以从引号中取出替换

echo "I am:" (whoami)