我怎么可以连接在Bash的字符串变量? [英] How can I concatenate string variables in Bash?
本文介绍了我怎么可以连接在Bash的字符串变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在PHP我想补充串在一起,就像这样:
$富=你好;
$ = foo的世界。
所以 $ foo的
将是Hello World的
我会怎么做,在击?
解决方案
富=你好
富=$ foo的世界
回声$ foo的
>你好,世界
在一般连接两个变量,你可以只写他们一个接一个:
A ='你好'
B =世界
C = $一个$ B
回声$ C
>你好,世界
In PHP I would add strings together like this:
$foo = "Hello";
$foo .= " World";
So $foo
would be "Hello World"
How would I do that 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
> helloworld
这篇关于我怎么可以连接在Bash的字符串变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文