linux-tutorial/codes/shell/示例脚本/逻辑控制/if-then-else语句.sh

12 lines
227 B
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
#testing the else section
testuser=badtest
if grep $testuser /etc/passwd
then
2019-10-10 08:56:31 +08:00
echo The files for user $testuser are:
ls -a /home/.b*
2019-05-10 11:17:57 +08:00
else
2019-10-10 08:56:31 +08:00
echo "The user name $testuser does not exist on this system"
2019-05-10 11:17:57 +08:00
fi