shell 字符串无法拼接

2025-05-12 02:46:36
推荐回答(3个)
回答1:

root@localhost:~# s1="hello"
root@localhost:~# s2="world"
root@localhost:~# echo ${s1}${s2}
helloworld
root@localhost:~# cat 1
s1="hello"
s2="world"
echo ${s1}${s2}
root@localhost:~# sh 1
helloworld
没有问题啊。你是不是bash
root@localhost:~# ll /bin/sh
lrwxrwxrwx 1 root root 4 4月 6 2016 /bin/sh -> bash

回答2:

用引号把echo后的两变量引起来

回答3:

你使用字符串连接符 "+" 试一试看看。即:echo ${$1}+${$2}