一 按照文件类型进行判断

Shell条件判断语句上
 
 
二 两种判断格式
test -e /root/install.log
[ -e /rout/install.log ]
第一个判断命令如果正确执行,则打印“yes”,否则打印“no”
[ -d /root ] && echo "yes" || "no"
 
三 实战
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
[[email protected] ~]# [ -e /root/test.txt ]
[[email protected] ~]# [ -e /root/test.txt2 ]
[[email protected] ~]# echo $?
1
[[email protected] ~]# [ -d /root ] && echo "yes" || "no"
yes
[[email protected] ~]# [ -e /root/test.txt ] && echo "yes" || "no"
yes
 
四 按照文件权限判断

Shell条件判断语句上
 
 
五 实战
[[email protected] ~]# [ -w /root/test.txt ] && echo "yes" || "no"
yes

相关文章:

  • 2022-12-23
  • 2022-01-11
  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-09-06
猜你喜欢
  • 2021-05-17
  • 2021-06-28
  • 2022-12-23
  • 2021-07-24
  • 2021-08-09
  • 2021-08-18
  • 2022-12-23
相关资源
相似解决方案