请教关于shell下字符串变量如何累加问题

2025-05-13 22:54:59
推荐回答(2个)
回答1:

字符串最好放到双引号中,防止中间有空格,如name中就可能存在空格。

改为:
total="${name}""${email}""${other}"
或者 total="$name""$email""$other"

回答2:

如果你用的是bash, 可以echo ${!cx_e}也可以eval echo \$$cx_e