1.Shell中控制流结构
#case 语句
- case $var in
- val1)
- body1
- ;;
- val2|val3)
- body2&3
- ;;
- esac
tab同if。可以都省
1 #!/bin/sh
2
3 m=Oct
4
5 case $m in
6 Jan)
7 mm=01
8 ;;
9 Oct)
10 mm=10
11 ;;
12 esac
13
14 echo $mm
#sh ...sh
#10
2.文件存在
4 if [ ! -e vb ];then
5 touch vb
6 fi
3.
64 while true;do
65 echo "Make sure USB Mass Storage is inserted."
66 echo "----------------------------------------------------------------"
67 echo "Press enter to continue..."
68 echo "----------------------------------------------------------------"
69 read Arg
70 case $Arg in
71 Y|y|YES|yes)
72 break
73 ;;
74 N|n|NO|no)
75 exit
76 ;;
77 "")
78 break
79 ;;
80 esac
81 done
4.
23 while true;do
24 echo "please input DHCP server IP address:"
25 read DHCP_SERVER
26 echo ${DHCP_SERVER}|grep "^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9
]\{1,3\}$" > /dev/null
27 num=$?
28 if [ $num = 1 ]
29 then
30 echo error ip,please enter correct
31 else
32 export DHCPSERVER=${DHCP_SERVER}
33 break
34 fi
35 done
5.
6.
7.
阅读(730) | 评论(0) | 转发(0) |