[求助]wiki里的shell教程:有个例子过不去?

sh/bash/dash/ksh/zsh等Shell脚本
回复
jerrywoo
帖子: 35
注册时间: 2006-10-12 20:23
来自: xmu
送出感谢: 0
接收感谢: 0
联系:

[求助]wiki里的shell教程:有个例子过不去?

#1

帖子 jerrywoo » 2006-11-17 20:26

下面是一个简单的示例:

#!/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 favourite OS?
1) Linux
2) Gnu Hurd
3) Free BSD
4) Other
#? 1
You have selected Linux


为什么我的结果是
user@user-desktop:~/test$ ./test03
What is your favourite OS?
./test03: 4: select: not found
./test03: 6: Syntax error: "done" unexpected
aBiNg
帖子: 1331
注册时间: 2006-07-09 12:22
来自: 南京
送出感谢: 0
接收感谢: 2 次

#2

帖子 aBiNg » 2006-11-18 12:55

可能Wiki写的时候有笔误吧

select是ksh/bash内建命令,sh解释不了...

:s/\<sh\>/bash/g
回复

回到 “Shell脚本”