if 条件语句
[root@localhost shell]# cat IfDemon01.sh
if [ -f /opt/jin.sh ];then
echo "this is a file "
else
echo "this is not a file"
fi[root@localhost shell]# bash -n IfDemon01.sh
[root@localhost shell]# bash IfDemon01.sh
this is a file
if 双分支语句
[root@localhost shell]# cat IfDemon02.sh
#!/bin/sh
if [ -d /etc/hosts ];then
echo "this is not a directory"
elif [ -f /etc/jin ]; then
echo "this is a file"
else
echo " it doesn't exist"
fi
[root@localhost shell]# bash -n IfDemon02.sh
[root@localhost shell]# bash IfDemon02.sh
it doesn't exist