文件测试
存在性测试
-a file: True if file exists
-e file:True if file exists
存在性及类别判断
-c file: True if file exists and is a character special file
-b file: True if file exists and is a block special file
-d file: True if file exists and is a directory
-f file: True if file exists and is a regular file
-h or -L file: True if file exists and is a symbolic link
-p file: True if file exists and is a namedd pipe(FIFO)
-S file: True if file exists and is a Socket file
文件权限测试
-r file: True if file exists and is readable
-w file: True if file exists and is writable
-x file: True if file exists and is execuatable
文件特殊权限测试
-g file: True if file exists and is set-group-id.(SGID特殊权限位)
-u file: True if file exists and is set-user-id.(SUID特殊权限位)
-k file: True if file exists and its ``sticky’’ bit is set.
文件大小测试
-s: True if file exists and its ``sticky’’ bit is set.
文件是否打开
-t fd True if file descriptor fd(文件描述符) is open and refers to a terminal.
-N file True if file exists and has been modified since it was last read.
-O file: 当前用户是否为文件属主
-G file: 当前用户是否为文件属组
双目测试
file1 -ef file2: True if file1 and file2 refer to the same device and inode numbers.(两个文件是否指向同一个设备上相同的inode)
文件版本测试
file1 -nt file2: True if file1 is newer (according to modification date) than file2, or if file1 exists and file2 does not.
file1 -ot file2: True if file1 is older than file2, or if file2 exists and file1 does not.