您的位置:首页 > 运维架构 > Shell

shell条件判断式语句

2015-06-02 14:39 423 查看


例:

[root@localhost ~]# ls
aa   anaconda-ks.cfg  cangls       install.log.syslog  sh        test3.sh  tmp
abc  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 no
yes
[root@localhost ~]# [ -e /root/install.logs ] && echo yes || echo no
no


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell