shell文件测试

文件测试

存在性测试

-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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值