1.if-then
if command
then
fi
[root@db-grassroots-61-001 script]# cat 2
#!/bin/bash
testuser=markgeng
if grep $testuser /etc/passwd
then
ls -a /home/$testuser/.b*
fi
2.if -then-else
if command
then
else
fi
[root@db-grassroots-61-001 script]# cat 2
#!/bin/bash
testuser=markgeng
if grep $testuser /etc/passwd
then
ls -a /home/$testuser/.b*
else
fi
3.嵌套if语句
if command1
then
elif command2
then
fi
4.if-then -elif
if command1
then
elif command2
then
elif command3
command set 3
elif command4
fi
发表评论
要发表评论,您必须先登录。