1 #!/bin/bash
2 #Porgram
3 # This program shows the user's choice.
4 #History
5 #2014/12/08
6 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
7 export PATH
8
9 read -p "Please input (Y/n):" yn
10 [ "$yn" == "Y" -o "$yn" == "y" ] && echo "OK.continue" && exit 0
11 [ "$yn" == "N" -o "$yn" == "n" ] && echo "Oh,interrupt!" && exit 0
12 echo "I don't know what your choice is" && exit 0
13
完全按照书上写的,但是运行错误。
root@default:~/shell# sh
sh06.shPlease input (Y/n):y
sh06.sh: 10: [: y: unexpected operator
sh06.sh: 11: [: y: unexpected operator
I don't know what your choice is
root@default:~/shell#
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/152446
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.