k668 发表于 2018-8-27 09:53:45

shell常见的文件属性检查

操作符          如果...则为真  

  
-b file         file为块设备文件
  

  
-c file         file为字符设备文件
  

  
-d file          file为目录
  

  
-e file          file存在
  

  
-f file          file为一般文件
  

  
-g file         file有设置它的setgid位
  

  
-h file          file为符号链接
  

  
-L file          同-h
  

  
-p file          file为管道
  

  
-r file          file可读
  

  
-S file          file为套接字(socket)
  

  
-s file          file非空
  

  
-u file          file有设置它的setuid位
  

  
-w file          file可写
  

  
-x file          file可执行,如果是目录,则file可被查找
  

  
-O file          你是file的所有者
  

  
-G file          file的组ID匹配你的ID
  

  
file1 -nt file2   file1比file2新
  

  
file1 -ot file2   file1比file2旧


页: [1]
查看完整版本: shell常见的文件属性检查