1. while 语句
while true
do
command1
if (command1 failed) break
command2
if (command2 failed) break
……
command n
if (command n failed) break
all commands ran successfully!
return 0
done
some commands failed
return -1
if [ -f /var/log/messages ]
then
echo "/var/log/messages exists."
fi 3. if/then/elif/else结构
case $select in
1)
echo “do open file operation”
;;
2)
echo “do display a file operation”
;;
3)
echo “do edit a file operation”
;;
4)
echo “do delete a file operation”
;;
*)
echo “There is nothing to do!”
exit 1
;;
esac