首页 > 系统服务 > 详细

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

时间:2015-05-05 16:55:12      阅读:275      评论:0      收藏:0      [点我收藏+]

例子一;

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

说明执行成功!

本文出自 “一天一点努力” 博客,请务必保留此出处http://java711.blog.51cto.com/1786533/1642028

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

原文:http://java711.blog.51cto.com/1786533/1642028

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!