shell部分test比较命令使用

来源:互联网 发布:淘宝香港站 编辑:程序博客网 时间:2024/05/17 02:43

 


文件比较:-------------------------------------------
-d file  检查file是否存在并且是一个目录
-e file  检查file是否存在
-f file  检查file是否存在并且是一个文件
-r file   检查file是否存在并且可读
-s file  检查file是否存在并且不为空
-w file  检查file是否存在并且可写
-x file  检查file是否存在并且可执行
-0 file  检查file是否存在并且被当前用户拥有
-G file  检查file是否存在并且默认组是否为当前用户组
file1 -nt file2 检查file1是否比file2新
file1 -ot file2 检查file1是否比file2旧

数值比较:-------------------------------------------
a -eq b  a是否等于b 
a -ge b  a是否大于或等于b
a -gt b  a是否大于b 
a -le b  a是否小于或等于b
a -lt b  a是否小于b  
a -ne b  a是否不等于b 

 

原创粉丝点击