bash shell 脚本中的连接字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9445259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 21:41:44 来源:igfitidea点击:
Concat strings in a shell script
提问by Webnet
How can I concat strings in shell? Is it just...
如何在 shell 中连接字符串?难道只是...
var = 'my';
var .= 'string';
?
?
回答by cnicutar
How about this:
这个怎么样:
var="${var}string"
回答by dldnh
It depends on the shell, but since question was tagged bash:
这取决于外壳,但由于问题被标记为 bash:
var='my'
var=$var'string'
回答by Ignacio Vazquez-Abrams
No. For various reasons.
不。出于各种原因。
# most sh-compatible shells
var="my"
var="$var string"
# advanced shells
var="my"
var+=" string"