@H_404_2@二 两种判断格式
test -e /root/install.log
[ -e /rout/install.log ]
第一个判断命令如果正确执行,则打印“yes”,否则打印“no”
[ -d /root ] && echo "yes" || "no"
@H_404_2@三 实战
[root@localhost ~]# ls
abc canyls Downloads Pictures Templates
abcd ChangeLog-2.6.0 initial-setup-ks.cfg Public test.txt
anaconda-ks.cfg Desktop linux-2.6.39.tar.bz2 sh Videos
cangls Documents Music student.txt XshellXftpPortable.zip
[root@localhost ~]# [ -e /root/test.txt ]
[root@localhost ~]# [ -e /root/test.txt2 ]
[root@localhost ~]# echo $?
1
[root@localhost ~]# [ -d /root ] && echo "yes" || "no"
yes
[root@localhost ~]# [ -e /root/test.txt ] && echo "yes" || "no"
yes
@H_404_2@五 实战
[root@localhost ~]# [ -w /root/test.txt ] && echo "yes" || "no"
yes