首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

shell脚本,该如何解决

2012-03-25 
shell脚本我在一个shell脚本中写了下面两个语句:accountcut -d : -f1 /etc/passwd | sort‘echo $accou

shell脚本
我在一个shell脚本中写了下面两个语句:
account='cut -d ":" -f1 /etc/passwd | sort‘
echo $account
在ubuntu下执行该脚本,为啥输出的还是cut -d ":" -f1 /etc/passwd | sort,而没有执行单引号中的内嵌指令呢?

[解决办法]
account=`cut -d ":" -f1 /etc/passwd | sort`

account=$(cut -d ":" -f1 /etc/passwd | sort)
后种方式更好

热点排行