linux 中实现字符串的拼接
001、简单测试
[root@pc1 test01]# str1=ab ## 测试字符串 [root@pc1 test01]# str2=xy [root@pc1 test01]# echo $str1 ## 测试字符串 ab [root@pc1 test01]# echo $str2 xy [root@pc1 test01]# str3="$str1 $str2" ## 字符串拼接 [root@pc1 test01]# echo $str3 ## 拼接效果 ab xy

002、循环拼接
[root@pc1 test01]# echo $str3 ab xy [root@pc1 test01]# for i in {1..5}; do str3="$str3 $i"; done ## 循环拼接 [root@pc1 test01]# echo $str3 ## 拼接效果 ab xy 1 2 3 4 5

。

浙公网安备 33010602011771号