test 比较
测试命令 test(更详细介绍见“逻辑判断”章节)
Demo
[root@localhost ~]# test -f /etc/passwd
[root@localhost ~]# echo $?
0
[root@localhost ~]# test -f /etc/passwd2
[root@localhost ~]# echo $?
1
[root@localhost ~]# [-d /etc]
bash: [-d: command not found...
[root@localhost ~]# [ -d /etc ]
[root@localhost ~]# echo $?
0
[root@localhost ~]# [ -e /etc ]
[root@localhost ~]# echo $?
0
[root@localhost ~]# [ 5 -gt 4 ]
[root@localhost ~]# echo $?
0
[root@localhost ~]# [ 5 -gt 6 ]
[root@localhost ~]# echo $?
1Last updated