安稳与你 提交于 2019-12-23 00:22:29
[root@localhost ~]# ! /bin/bash
case "$1" in
[root@localhost ~]# case "$1" in
> start)
>  echo "Starthing ABC service"
> ;;
> stop)
> echo "Stop ABC service"
> ;;
> force-relonad|restart)
> $0 stop
> $0 start
> ;;
> status)
> echo "Display status of ABC service"
> ;;
> *)
> echo "Usage: $0 {start|stop|restart|force-reload|status}"
> exit 1
> ;;
> esac
Usage: /bin/bash {start|stop|restart|force-reload|status}
exit
[root@localhost ~]# if [ $# = 0 ]
> then
> echo "Usage: $0 : <number>"
> else
> count=$l
> while [ $count -gt 0 ]
> do
>    count=`expr $count -l`
>    echo -e "\015 $count \c"
> sleep l
> done
> fi
Usage: sh : <number>
[root@localhost ~]# get_attr()
> {
> while true
> do
> echo -e "$2 [$3] : \c"; read val
> [ "$val" = "" ] && val=$3
> for i in $4
> do
> [ "$val" = "$i" ] && break 2
> done
> echo -e "**** Invalid choice \"$val\", must be in \"$4\""
> eval "$1=$val
> }
> [root@localhost ~]# get_attr COLOR "Color of the box" white \
> >   "red green pink white black"
Color of the box [white] : red
[root@localhost ~]# get_attr DAY "Day of the week" mon \
>   "sun mon tue wed thu fri sat"
Day of the week [mon] :
[root@localhost ~]# get_attr ROLE "Your role in the system" student \
>   "admin student tescher guest"
Your role in the system [student] : echo "COLOR=$COLOR DAY=$DAY ROLE=$ROLE"
**** Invalid choice "echo "COLOR=$COLOR DAY=$DAY ROLE=$ROLE"", must be in "admin
 student tescher guest"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!