centos下单引号括起来的shell脚本不执行解决方法


例如:

touch test.sh
vi test.sh
input 
test='echo "test*"|grep [a-zA-Z0-9] |wc -c'
echo $test
保存,退出vi;
sh test.sh
结果:echo "test*"|grep [a-zA-Z0-9] |wc -c
说明没有执行;
我们把一对单引号 修改成$();结果类容如下:
test=$(echo "test*"|grep [a-zA-Z0-9] |wc -c)
echo $test
保存,退出vi;
sh test.sh
结果:6
说明执行成功!

centos下单引号括起来的shell脚本不执行解决方法



centos下单引号括起来的shell脚本不执行解决方法