源程序是这样的
#!/bin/sh
echo "enter password"
read trythis
while [ "$trythis" !=" secret" ];do
echo "sorry,try again"
read trythis
done
exit 0
书上提示的运行结果是
enter password
password
sorry,try again
secret
$
可是我运行的结果是
[root@localhost ~]# /bin/sh while
enter password
password
while: line 4: [: password: unary operator expected
[root@localhost ~]#
求解释
tianfeng1988 于 2013-02-26 10:10:38发表:
初学Linux,{:2_92:},各位大侠多多关照
GJ1203 于 2013-02-23 20:59:55发表:
shell编程对于空格的位置要求很严格....注意检查...
于 2012-03-07 19:20:57发表:
while [ "$trythis" !=" secret" ];do
改成
while [ "$trythis" != "secret" ];do
注意空格位置。