If-then结构控制的分类:
(1)单分支if结构,此类分支结构,当条件满足时就会执行then后面的语句,不满足就直接退出判断语句
if [条件];then
语句...
fi
程序演练:
Shell实例1:
[root@ChangerLee 顺序结构]# cat id_ifthen_dan.sh
#!/bin/bash
#if_then单分支控制结构演练
id $1
if [ $? -eq 0 ]
then
echo "$1 user exists!"
fi
[root@ChangerLee 顺序结构]# sh id_ifthen_dan.sh apachedid: apached: no such user