码迷,mamicode.com
首页 > 系统相关 > 详细

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

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

标签:shell   centos   单引号问题   

例子一;

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脚本不执行解决方法

标签:shell   centos   单引号问题   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!