[root@gfs-node122 shell]# cat 3.sh
#!/bin/bash
RED_COLOR='\E[1;31m'
GREEN_COLOR='\E[1;32m'
YELLOW_COLOR='\E[1;33m'
BLUE_COLOR='\E[1;34m'
RES='\E[0m'
echo '
=====================
1.Strawberry
2.Blueberry
3.Watermelon
4.tangerine
=====================
'
read -p "pls select a num:" num
case "$num" in
1)
echo -e "${RED_COLOR}Strawberry 草莓${RES}"
;;
2)
echo -e "${GREEN_COLOR}Blueberry 蓝莓${RES}"
;;
3)
echo -e "${YELLOW_COLOR}Watermelon 西瓜${RES}"
;;
4)
echo -e "${BLUE_COLOR}tangerine 橘子${RES}"
;;
*)
echo "muse be {1|2|3|4}"
esac
执行脚本:
[root@gfs-node122 shell]# bash 3.sh
=====================
1.Strawberry
2.Blueberry
3.Watermelon
4.tangerine
=====================
pls select a num:1
Strawberry 草莓
[root@gfs-node122 shell]# bash 3.sh
=====================
1.Strawberry
2.Blueberry
3.Watermelon
4.tangerine
=====================
pls select a num:2
Blueberry 蓝莓
[root@gfs-node122 shell]# bash 3.sh
=====================
1.Strawberry
2.Blueberry
3.Watermelon
4.tangerine
=====================
pls select a num:34
muse be {1|2|3|4}
[root@gfs-node122 shell]# bash 3.sh
=====================
1.Strawberry
2.Blueberry
3.Watermelon
4.tangerine
=====================
pls select a num:3
Watermelon 西瓜
[root@gfs-node122 shell]# bash 3.sh
=====================
1.Strawberry
2.Blueberry
3.Watermelon
4.tangerine
=====================
pls select a num:4
tangerine 橘子