且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Bash 中连接字符串变量

更新时间:2023-02-21 18:51:47

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