Concat strings in a shell script [duplicate]

别等时光非礼了梦想. 提交于 2019-12-20 09:09:29

问题


How can I concat strings in shell? Is it just...

var = 'my';
var .= 'string';

?


回答1:


How about this:

var="${var}string"



回答2:


It depends on the shell, but since question was tagged bash:

var='my'
var=$var'string'



回答3:


No. For various reasons.

# most sh-compatible shells
var="my"
var="$var string"

# advanced shells
var="my"
var+=" string"


来源:https://stackoverflow.com/questions/9445259/concat-strings-in-a-shell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!