本文介绍了如何在 Bash 中连接字符串变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 PHP 中,字符串按如下方式连接在一起:
In PHP, strings are concatenated together as follows:
$foo = "Hello"; $foo .= " World";这里,$foo 变成了Hello World".
Here, $foo becomes "Hello World".
这是如何在 Bash 中实现的?
How is this accomplished in Bash?
推荐答案 foo="Hello" foo="${foo} World" echo "${foo}" > Hello World通常要连接两个变量,您可以一个接一个地编写它们:
In general to concatenate two variables you can just write them one after another:
a='Hello' b='World' c="${a} ${b}" echo "${c}" > Hello World更多推荐
如何在 Bash 中连接字符串变量
发布评论