cat, tac, nl, more, less, head, tail, od(3)

modification time (mtime):
当该文件的『内容数据』变更时,就会升级这个时间!内容数据指的是文件的内容,而不是文件的属性或权限喔!

status time (ctime):
当该文件的『状态 (status)』改变时,就会升级这个时间,举例来说,像是权限与属性被更改了,都会升级这个时间啊。

access time (atime):
当『该文件的内容被取用』时,就会升级这个读取时间 (access)。举例来说,我们使用 cat 去读取 /etc/man.config , 就会升级该文件的 atime 了。

cat, tac, nl, more, less, head, tail, od

在默认的情况下,ls 显示出来的是该文件的 mtime ,也就是这个文件的内容上次被更动的时间。

[root@www ~]# touch [-acdmt] 文件 选项与参数: -a :仅修订 access time; -c :仅修改文件的时间,若该文件不存在则不创建新文件; -d :后面可以接欲修订的日期而不用目前的日期,也可以使用 --date="日期或时间" -m :仅修改 mtime ; -t :后面可以接欲修订的时间而不用目前的时间,格式为[YYMMDDhhmm] 范例一:新建一个空的文件并观察时间 [root@www ~]# cd /tmp [root@www tmp]# touch testtouch [root@www tmp]# ls -l testtouch -rw-r--r-- 1 root root 0 Sep 25 21:09 testtouch # 注意到,这个文件的大小是 0 呢!在默认的状态下,如果 touch 后面有接文件, # 则该文件的三个时间 (atime/ctime/mtime) 都会升级为目前的时间。若该文件不存在, # 则会主动的创建一个新的空的文件喔!例如上面这个例子! 范例二:将 ~/.bashrc 复制成为 bashrc,假设复制完全的属性,检查其日期 [root@www tmp]# cp -a ~/.bashrc bashrc [root@www tmp]# ll bashrc; ll --time=atime bashrc; ll --time=ctime bashrc -rw-r--r-- 1 root root 176 Jan 6 2007 bashrc <==这是 mtime -rw-r--r-- 1 root root 176 Sep 25 21:11 bashrc <==这是 atime -rw-r--r-- 1 root root 176 Sep 25 21:12 bashrc <==这是 ctime 范例三:修改案例二的 bashrc 文件,将日期调整为两天前 [root@www tmp]# touch -d "2 days ago" bashrc [root@www tmp]# ll bashrc; ll --time=atime bashrc; ll --time=ctime bashrc -rw-r--r-- 1 root root 176 Sep 23 21:23 bashrc -rw-r--r-- 1 root root 176 Sep 23 21:23 bashrc -rw-r--r-- 1 root root 176 Sep 25 21:23 bashrc # 跟上个范例比较看看,本来是 25 日的变成了 23 日了 (atime/mtime)~ # 不过, ctime 并没有跟著改变喔! 范例四:将上个范例的 bashrc 日期改为 2007/09/15 2:02 [root@www tmp]# touch -t 0709150202 bashrc [root@www tmp]# ll bashrc; ll --time=atime bashrc; ll --time=ctime bashrc -rw-r--r-- 1 root root 176 Sep 15 2007 bashrc -rw-r--r-- 1 root root 176 Sep 15 2007 bashrc -rw-r--r-- 1 root root 176 Sep 25 21:25 bashrc # 注意看看,日期在 atime 与 mtime 都改变了,但是 ctime 则是记录目前的时间!

本文永久更新链接地址

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/16121.html