Fish shell 命令替换 [英] Fish shell command subsitution

查看:35
本文介绍了Fish shell 命令替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there a better way to do command substitution in fish shell?

在 bash 中我可以做到:

In bash I can do:

$ echo $(whoami) 
user

$ echo "I am: $(whoami)" 
I am: user

但在鱼看来我必须这样做:

But in fish is looks like I have to do:

$ echo (whoami) 
user

$ echo "I am: (whoami)" 
I am: (whoami)

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

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

Is that the recommended way to do command substitution in fish where the substitution needs to happen inside a quoted string?

推荐答案

你可以直接从引号中取出替换

You could just pull the substitution out of the quotes

echo "I am:" (whoami)

这篇关于Fish shell 命令替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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