今天在查找用strings命令是忘记要不要首字母要不要大写,于是就用tab键补全,结果列出了stat命令。这个命令的名字让我感动好奇,之前从来没用过。
于是stat --help了一下,发现这命令原来非常有用。google了一下,该命令的中文资料极少,或许Linux大侠们都不屑于将man文档翻译成中文吧。
下面是stat --help输出
Usage: stat [OPTION] FILE...
Display file or filesystem status.
Display file or filesystem status.
-f, --filesystem display filesystem status instead of file status
-c --format=FORMAT use the specified FORMAT instead of the default
-L, --dereference follow links
-t, --terse print the information in terse form
--help display this help and exit
--version output version information and exit
-c --format=FORMAT use the specified FORMAT instead of the default
-L, --dereference follow links
-t, --terse print the information in terse form
--help display this help and exit
--version output version information and exit
The valid format sequences for files (without --filesystem):
%A - Access rights in human readable form
%a - Access rights in octal
%b - Number of blocks allocated
%D - Device number in hex
%d - Device number in decimal
%F - File type
%f - raw mode in hex
%G - Group name of owner
%g - Group ID of owner
%h - Number of hard links
%i - Inode number
%N - Quoted File name with dereference if symbolic link
%n - File name
%o - IO block size
%s - Total size, in bytes
%T - Minor device type in hex
%t - Major device type in hex
%U - User name of owner
%u - User ID of owner
%X - Time of last access as seconds since Epoch
%x - Time of last access
%Y - Time of last modification as seconds since Epoch
%y - Time of last modification
%Z - Time of last change as seconds since Epoch
%z - Time of last change
%a - Access rights in octal
%b - Number of blocks allocated
%D - Device number in hex
%d - Device number in decimal
%F - File type
%f - raw mode in hex
%G - Group name of owner
%g - Group ID of owner
%h - Number of hard links
%i - Inode number
%N - Quoted File name with dereference if symbolic link
%n - File name
%o - IO block size
%s - Total size, in bytes
%T - Minor device type in hex
%t - Major device type in hex
%U - User name of owner
%u - User ID of owner
%X - Time of last access as seconds since Epoch
%x - Time of last access
%Y - Time of last modification as seconds since Epoch
%y - Time of last modification
%Z - Time of last change as seconds since Epoch
%z - Time of last change
Valid format sequences for file systems:
%a - Free blocks available to non-superuser
%b - Total data blocks in file system
%c - Total file nodes in file system
%d - Free file nodes in file system
%f - Free blocks in file system
%i - File System id in hex
%l - Maximum length of filenames
%n - File name
%s - Optimal transfer block size
%T - Type in human readable form
%t - Type in hex
%b - Total data blocks in file system
%c - Total file nodes in file system
%d - Free file nodes in file system
%f - Free blocks in file system
%i - File System id in hex
%l - Maximum length of filenames
%n - File name
%s - Optimal transfer block size
%T - Type in human readable form
%t - Type in hex
后面的输出格式化其实大部分情况都是不需要的。
这个命令可以比ls -l 显示出更多的文件相关信息。该命令对我来说最大的好处是可以查看到一个文件最后访问的时间,最后修改时间。
当我换了一个页面在前台刷新发现和之前页面一样时,只要用这个命令看一下新换的文件是否被访问过,就能确认是不是缓存没刷新的问题了。
还是看看输出信息吧:
# stat java
File: `java'
Size: 64812 Blocks: 128 IO Block: 4096 Regular File
Device: 811h/2065d Inode: 711 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1818/ star) Gid: ( 1818/ star)
Access: 2009-01-08 14:05:37.000000000 +0800
Modify: 2005-11-11 04:48:31.000000000 +0800
Change: 2008-08-28 14:26:50.000000000 +0800
File: `java'
Size: 64812 Blocks: 128 IO Block: 4096 Regular File
Device: 811h/2065d Inode: 711 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1818/ star) Gid: ( 1818/ star)
Access: 2009-01-08 14:05:37.000000000 +0800
Modify: 2005-11-11 04:48:31.000000000 +0800
Change: 2008-08-28 14:26:50.000000000 +0800