当前位置: 技术问答>linux和unix
linux下shell脚本中的语法错误,这是什么回事啊?
来源: 互联网 发布时间:2016-07-17
本文导语: 我在linux下拷贝了一个小脚本,内容如下 #!/bin/sh echo "What is your favourite OS?" select var in "Linux" "Gnu Hurd" "Free BSD" "Other"; do break; done echo "You have selected $var" 可是运行的时候出现了一下显示,为什么和...
我在linux下拷贝了一个小脚本,内容如下
#!/bin/sh
echo "What is your favourite OS?"
select var in "Linux" "Gnu Hurd" "Free BSD" "Other"; do
break;
done
echo "You have selected $var"
可是运行的时候出现了一下显示,为什么和网上说的应该显示的内容不一样呢?
What is your favorite OS ?
./test1: 3: select: Permission denied
./test1: 5: Syntax error: "done" unexpected
上面是我运行时的结果,网上说出现下面的才是对的啊!
What is your favourite OS?
1) Linux
2) Gnu Hurd
3) Free BSD
4) Other
#? 1
You have selected Linux
请知道的同志给解解,先谢过了啊!
#!/bin/sh
echo "What is your favourite OS?"
select var in "Linux" "Gnu Hurd" "Free BSD" "Other"; do
break;
done
echo "You have selected $var"
可是运行的时候出现了一下显示,为什么和网上说的应该显示的内容不一样呢?
What is your favorite OS ?
./test1: 3: select: Permission denied
./test1: 5: Syntax error: "done" unexpected
上面是我运行时的结果,网上说出现下面的才是对的啊!
What is your favourite OS?
1) Linux
2) Gnu Hurd
3) Free BSD
4) Other
#? 1
You have selected Linux
请知道的同志给解解,先谢过了啊!
|
楼主只要把#!/bin/sh改为#!/bin/bash就能正常运行了,这是和Shell相关的.