文件的时间参数

linux下的文件都会被记录很多的时间参数,下面介绍主要的3种时间参数:
mtime(modification time ):当该文件的“内容数据”(文件的内容)被更改时,就会更新这个时间
ctime(status time):当文件的“状态”(例如权限,属性)被更改时,会更新这个时间
atime(access time):当文件的内容别使用(例如读取执行cat,more,less等操作),就会更新该时间
下面通过举例来说明:
[root@localhost 桌面]# who i am
root     pts/0        2015-04-17 23:01 (:0.0)
[root@localhost 桌面]# lsb_release -a  
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.3 (Final)
Release: 6.3
Codename: Final

[root@localhost 桌面]# man ls
Cannot open the message catalog "man" for locale "zh_CN.UTF-8"
(NLSPATH="/usr/share/locale/%l/LC_MESSAGES/%N")


Formatting page, please wait..
.........................
.........................
 --time=WORD
              with  -l,  show time as WORD instead of modification time: atime
              -u, access -u, use -u, ctime -c, or  status  -c;  use  specified
              time as sort key if --sort=time
.............................
.............................
上面已经给了我们后面所带的参数:
-u,-c (也可以用ctime,atime) 不带参数默认就是mtime
上面我们可以知道ls显示出来的是mtime,也就是文件内容被更改的时间。
[root@localhost 桌面]# touch a
[root@localhost 桌面]# date
2015年 04月 17日 星期五 23:14:13 CST
mtime:
[root@localhost 桌面]# vim a
[root@localhost 桌面]# date
2015年 04月 17日 星期五 23:15:39 CST
[root@localhost 桌面]# ls -al a
-rw-r--r--. 1 root root 15 4月  17 23:15 a

ctime:
[root@localhost 桌面]# date
2015年 04月 17日 星期五 23:21:05 CST
[root@localhost 桌面]# chmod 700 a
[root@localhost 桌面]# ls -al --time=ctime a
-rwx------. 1 root root 15 4月  17 23:21 a


atime:
[root@localhost 桌面]# date
2015年 04月 17日 星期五 23:21:53 CST
[root@localhost 桌面]# cat a
hello,diy_os!
[root@localhost 桌面]# ls -al --time=atime a
-rwx------. 1 root root 15 4月  17 23:21 a


经常使用的是mtime,看重文件的内容什么时候被更改了,这个对于使用linux的用户很重要。


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值