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.sh
Please 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#
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.sh
Please 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#