1单分支语句
2多分支语句
例子 判断apache是否运行
#!/bin/bash
#author
port=$(nmap -sT IP地址 | grep tcp | grep httpd | awk '{print $2}')
if [ "$port"==open ]
then
echo "$(date) httpd is run " >> /tmp/httpd_run.log
else
/etc/rc.d/init.d/httpd restart &> /dev/null
echo "$(date) httpd is restart" >> /tmp/httpd_err.log
fi