文件属性比较
文件属性比较是另一个常用的条件判断类型。
-a file :file 存在
-d file :file存在并是一个目录
-e file :file 存在,同- a
-f file :file 存在并且是一个常规的文件(不是目录或者其他特殊类型文件)
-r file :有读的权限
-s file :文件存在且不为空
-w file :有写的权限
-x file :有执行的权限,或者对于目录有search的权限
-N file :在上次读取后,文件有改动
-O file :own所属的文件
-G file :group所属的文件
file1 -nt file2 :file1 比 file2 更新,以最后更新时间为准
file1 -ot file2 :file1 比 file2 更旧 ,以最后更新时间为准
转载于:https://blog.51cto.com/foolishfish/1372776