test1.sh: 3: select: not found

sh/bash/dash/ksh/zsh等Shell脚本
回复
litao19
帖子: 29
注册时间: 2006-08-18 9:48
送出感谢: 0
接收感谢: 0

test1.sh: 3: select: not found

#1

帖子 litao19 » 2007-04-24 11:04

#!/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"

这是本论坛“SHELL编程基础”里面的,怎么改呢?
ziyun
帖子: 262
注册时间: 2007-03-29 12:59
送出感谢: 0
接收感谢: 0

#2

帖子 ziyun » 2007-04-24 15:35

代码: 全选

#!/bin/bash
echo "What is your favourite OS?"
select var in "Linux" "Gnu Hurd" "Free BSD" "Other"; do
break
done
echo "You have selected $var"
必须是/bin/bash
必须用chmod +x然后用文件名执行
break前有空格也会报错
我试了很久才成功
litao19
帖子: 29
注册时间: 2006-08-18 9:48
送出感谢: 0
接收感谢: 0

#3

帖子 litao19 » 2007-04-24 15:53

ziyun 写了:

代码: 全选

#!/bin/bash
echo "What is your favourite OS?"
select var in "Linux" "Gnu Hurd" "Free BSD" "Other"; do
break
done
echo "You have selected $var"
必须是/bin/bash
必须用chmod +x然后用文件名执行
break前有空格也会报错
我试了很久才成功
谢谢。我试了下,用chmod +x然后用文件名执行就可以了,break前有空格也没关系。
但是为什么用 sh filename 执行不行呢?
ziyun
帖子: 262
注册时间: 2007-03-29 12:59
送出感谢: 0
接收感谢: 0

#4

帖子 ziyun » 2007-04-24 17:30

我也不知道为什么
我这里前面用#!/bin/sh是不行的
头像
alinmn
帖子: 185
注册时间: 2006-05-19 21:42
来自: NIT
送出感谢: 0
接收感谢: 0

#5

帖子 alinmn » 2007-04-26 14:45

现在的/bin/sh 是指向 /bin/dash的,用起来不习惯,sudo ln -sf /bin/bash /bin/sh改一下就可以了
头像
linwhwylb
帖子: 78
注册时间: 2009-07-14 10:26
送出感谢: 0
接收感谢: 0

Re: test1.sh: 3: select: not found

#6

帖子 linwhwylb » 2011-01-01 9:23

原来是这样子,学习了~~
Ubuntu philosophy:that software should be available free of charge, that software tools should be usable by people in their local language, and that people should have the freedom to customize and alter their software in whatever way they need.
回复

回到 “Shell脚本”