stat命令

    在Linux中,没有文件创建时间的概念。只有文件的访问时间、修改时间、状态改变时间。也就是说不能知道文件的创建时间。但如果文件创建后就没有修改过,修改时间=创建时间;如果文件创建后,状态就没有改变过,那么状态改变时间=创建时间;如果文件创建后,没有被读取过,那么访问时间=创建时间,这个基本不太可能。

1.与文件相关的几个时间

(1)访问时间,读一次这个文件的内容,这个时间就会更新。比如对这个文件使用more命令。ls、stat命令都不会修改文件的访问时间。

(2)修改时间,对文件内容修改一次,这个时间就会更新。比如:vi后保存文件。ls -l列出的时间就是这个时间

(3)状态改变时间。通过chmod命令更改一次文件属性,这个时间就会更新。查看文件的详细的状态、准确的修改时间等,可以通过stat命令 文件名。

  比如: [jing@zhjh c]$ stat temp.c

  引用:

  File: 'temp.c'

  Size: 66 Blocks: 8 IO Block: 4096 \u4e00\u822c\u6587\u4ef6

  Device: 807h/2055d Inode: 1191481 Links: 1

  Access: (0664/-rw-rw-r--) Uid: ( 500/ jing) Gid: ( 500/ jing)

  Access: 2008-03-12 20:19:45.000000000 0800

  Modify: 2008-03-12 20:19:45.000000000 0800

  Change: 2008-03-12 20:19:45.000000000 0800

  说明:Access访问时间。Modify修改时间。Change状态改变时间。可以stat *查看这个目录所有文件的状态

2.用法

Usage: stat [OPTION] FILE...
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
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
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


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值