开始我认为是这样的:
[root@jiangyi02.sqa.zmf /home/ahao.mah/ALIOS_TEST]
#cat bbb.sh
#!/bin/sh
eval $1_new=123
eval $1_old=100
eval echo \${$1_new}
eval echo "\${$1_new} - \${$1_old}" | bc
aaa=`eval echo "\${$1_new} - \${$1_old}" | bc`
echo $aaa
[root@jiangyi02.sqa.zmf /home/ahao.mah/ALIOS_TEST]
#sh bbb.sh aa
123
23
bbb.sh: line 6: ${$1_new} - ${$1_old}: bad substitution
其实,在使用eval的时候,如果使用了 ``需要 使用两个\
#cat bbb.sh
#!/bin/sh
eval $1_new=123
eval $1_old=100
eval echo \${$1_new}
eval echo "\${$1_new} - \${$1_old}" | bc
aaa=`eval echo "\\${$1_new} - \\${$1_old}" | bc`
echo $aaa
[root@jiangyi02.sqa.zmf /home/ahao.mah/ALIOS_TEST]
#sh bbb.sh aa
123
23
23