fateame 发表于 2018-5-21 06:49:50

Linux stat

stat
-L, --dereference   follow links如果是链接文件,则获取原文件信息
-Z, --context         print the security context information if available
                               打印SElinux安全上下文信息
-f, --file-system   display file system status instead of file status
                              显示文件所在的文件系统的状态
-c--format=FORMAT   use the specified FORMAT instead of the default;
                        output a newline after each use of FORMAT
                        自定义输出格式,结尾有换行
      --printf=FORMAT   like --format, but interpret backslash escapes,
                        and do not output a mandatory trailing newline.
                        If you want a newline, include \n in FORMAT.
                        自定义输出格式,结尾无换行符,需手动添加
-t, --terse         print the information in terse form
                           以简洁的形式打印输出信息(在没有改变输出格式的情况下)
      --help   display this help and exit
                  打印帮助信息
      --versionoutput version information and exit
                     打印版本信息并退出
可选的文件信息输出格式
%a   Access rights in octal 八进制格式的文件访问权限   
%A   Access rights in human readable form 可读形式访问权限(ls -l情况下显示的样子)
%b   Number of blocks allocated (see %B)分配的块数(单位参照%B的数值)
%B   The size in bytes of each block reported by %b
          每个块的大小(这个值是指硬盘上存储单元块的大小,与格式化的block块大小不同)
%d   Device number in decimal设备号(10进制)
%D   Device number in hex 设备号(十六进制)
%f   Raw mode in hex raw模式(十六进制,可以百度一下raw的意思)
%F   File type 文件类型
%g   Group ID of owner 文件所有者的组ID
%G   Group name of owner 文件所有者的组名
%h   Number of hard links    硬链接的数量(文件本身算1个)
%i   Inode numberinode号
%n   File name文件名
%N   Quoted file name with dereference if symbolic link
         取消软连接的文件名引用,变成普通字符串
%o   I/O block size   系统格式化block的大小
%s   Total size, in bytes   文件大小(单位byte)
%t   Major device type in hex 主要设备类型(十六进制)
%T   Minor device type in hex 次要设备类型(十六进制)
%u   User ID of owner所有者的用户ID
%U   User name of owner 所有者的用户名
%x   Time of last access 最后访问时间
%X   Time of last access as seconds since Epoch最后一次访问时间(大纪元秒)
%y   Time of last modification 最后修改时间(内容改变)
%Y   Time of last modification as seconds since Epoch 最后修改时间(内容改变)
%z   Time of last change 最后改变时间(文件属性,权限所有者等,格式大纪元秒)
%Z   Time of last change as seconds since Epoch
         最后改变时间(文件属性,权限所有者等,格式大纪元秒)
stat -c "%a %A %b %B %d %D %f %F %g %G %h %i %n %N %o %s %t %T %u %U %x %X %y %Y %z %Z" file
可选的分区信息输出格式
%a   Free blocks available to non-superuser 普通用户可用的block数量      
%b   Total data blocks in file system 分区的总数据块数量      
%c   Total file nodes in file system 文件系统的inode总数      
%d   Free file nodes in file system 空闲inode数量      
%f   Free blocks in file system 可用的block数量      
%C   Security context in SELinux selinux 安全上下文      
%i   File System ID in hex分区ID(十六进制)
%l   Maximum length of filenames 分区文件名最大长度      
%n   File name文件名      
%s   Block size (for faster transfers) 块大小(都是系统block的大小)
%S   Fundamental block size (for block counts) 基本块大小(都是系统block的大小)
%t   Type in hex 文件系统类型(格式化的类型,十六进制)
%T   Type in human readable form 文件系统类型(格式化的类型,可读形式)
stat -f -c "%a %b %c %d %f %C %i %l %n %s %S %t %T" file
  
页: [1]
查看完整版本: Linux stat