shell条件判断式语句

来源:互联网 发布:江苏老快三遗漏数据 编辑:程序博客网 时间:2024/05/24 04:14

按照文件类型进行判断
例:

[root@localhost ~]# lsaa   anaconda-ks.cfg  cangls       install.log.syslog  sh        test3.sh  tmpabc  bols             install.log  japan               test2.sh  test.sh###判断root下install.log文件是否存在 注意空格[root@localhost ~]# [ -e /root/install.log ] [root@localhost ~]# echo $?0[root@localhost ~]# [ -e /root/installs.slog ] [root@localhost ~]# echo $?1[root@localhost ~]# [ -e /root/install.log ] && echo yes || echo noyes[root@localhost ~]# [ -e /root/install.logs ] && echo yes || echo nono

按照文件权限进行判断

0 0
原创粉丝点击