语句1 语句1 elif 条件2 elif 条件2 then then 语句2 语句2 fi 、、、 else 语句n fi 实例:1) if [ -x /sbin/quotaon ] then /sbin/quotaon –avug else echo “quotaon no exists.” fi 2)if [ -x /etc/crontab/ ] then echo “crontab file exists.” elif [-x/var/spool/cron/root] then echo “root’s crontab file exists.” fi
格式:Case 参数 in 值1) 语句1 ;; 值2) 语句2 ;; 、、、、、 *)语句N;; esac 实例: #Vi /etc/quotaman #! /bin/bash case “$1” in start) /sbin/quataon –avug ;; stop) /sbin/quotaoff –avug ;; restart) /sbin/quotaoff –avug /sbin/quotaon -avug ;; *) echo “enter start/stop/restart” ;; esac
格式:select 参数 in 字符串 |