[root@hunt1574 ~]# sh test.sh
1) January
2) February
3) March
4) April
5) May
6) June
7) July
8) August
9) September
10) October
11) November
12) December
13) stop
enter your choices:1
You chose number is January.
The choice number is 1.
enter your choices:09
You chose number is September.
The choice number is 09.
enter your choices:90
Invalid entry.
enter your choices:13
Thanks!
脚本内容:
#!/bin/bash
COLUMNS=20
PS3="enter your choices:"
select input in January February March April May June July August September October November December stop
do
if [ "$input" == "" ];then
echo -e "Invalid entry.\n"
continue
elif [ $input = stop ];then
echo "Thanks!"
break
fi
echo "You chose number is $input."
echo -e "The choice number is $REPLY.\n "
done
[root@hunt1574 ~]# sh test.sh
1) January 4) April 7) July 10) October 13) stop
2) February 5) May 8) August 11) November
3) March 6) June 9) September 12) December