linux文件时间的查看和改动touch
2017-06-20 09:48
405 查看
1. linux文件的时间
linux下文件时间主要有以下三种:1.1 modification time(mtime)
文件改动时间。即文件内容的改动时,更新这个时间。不包含文件权限和属性的改动。使用ls -l查看。默认显示时间为mtime
$ ls -l uconv.h -rw-rw-r-- 1 work work 1808 Jul 23 2013 uconv.h
1.2 status time(ctime)
文件状态status的改动时间,如文件的权限和属性改动时更新这个时间。使用 ls --time=ctime 查看
$ ls -l --time=ctime uconv.h -rw-rw-r-- 1 work work 1808 Jul 23 2013 uconv.h
1.3 access time(atime)
文件訪问时间,当文件内容被获取时。更新这个时间。使用 ls --time=actime 查看
$ ls -l --time=atime uconv.h -rw-rw-r-- 1 work work 1808 Dec 12 2013 uconv.h
2. 改动文件的时间
假设须要改动上述三个时间,使用touch命令来改动。touch filename ,假设文件不存在,则新建一个文件。
$ touch --help Usage: touch [OPTION]... FILE... Update the access and modification times of each FILE to the current time. -a change only the access time 改动訪问时间 -c, --no-create do not create any files 改动文件三个时间,不存在则不创建 -d, --date=STRING parse STRING and use it instead of current time 指定时间取代当前时间 -f (ignored) -m change only the modification time 改动mtime -r, --reference=FILE use this file's times instead of current time -t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time 指定改动时间
比如:
$ touch -d "2 days ago" uconv.h $ ll uconv.h ; ll --time=atime uconv.h ; ll --time=ctime uconv.h ; -rw-rw-r-- 1 work work 1808 Jun 13 18:17 uconv.h -rw-rw-r-- 1 work work 1808 Jun 13 18:17 uconv.h -rw-rw-r-- 1 work work 1808 Jun 15 18:17 uconv.h将mtime和atime改动为两天前,ctime没变。
$ touch -t 201406142020 uconv.h $ ll uconv.h ; ll --time=atime uconv.h ; ll --time=ctime uconv.h ; -rw-rw-r-- 1 work work 1808 Jun 14 20:20 uconv.h -rw-rw-r-- 1 work work 1808 Jun 14 20:20 uconv.h -rw-rw-r-- 1 work work 1808 Jun 15 18:23 uconv.hatime和mtime都变了,可是ctime变成了当前时间。
使用cp命令。-a保持原属性。
$ cp -a uconv.h uconv.h1 $ ll uconv.h1 ; ll --time=atime uconv.h1 ; ll --time=ctime uconv.h1 ; -rw-rw-r-- 1 work work 1808 Jun 14 20:20 uconv.h1 -rw-rw-r-- 1 work work 1808 Jun 15 18:25 uconv.h1 -rw-rw-r-- 1 work work 1808 Jun 15 18:27 uconv.h1mtime和atime都保持原文件不变,可是ctime变成当前时间
地址:http://blog.csdn.net/yonggang7/article/details/31008607
相关文章推荐
- linux文件时间的查看和修改touch
- linux 和freebsd查看文件修改、进入时间
- linux 下查看文件修改时间 等
- linux 下查看文件修改时间 等
- Linux系统下查看某文件修改的时间戳 查看某文件何时被修改过
- Linux目录与文件创建时间 / 修改时间 / 访问时间 / 指令 touch(鸟哥的Linux私房菜基础学习篇第三版-第七章)
- Linux下如何查看文件秒级修改及访问时间
- linux 下查看文件修改时间
- 在Linux下,一个文件也有三种时间,分别是:访问时间、修改时间、状态改动时间
- Linux下如何查看文件秒级修改及访问时间
- wlinux touch命令参数及用法详解---linux修改文件的时间
- 如何在Linux操作系统查看文件创建时间
- 在Linux下文件的三种时间标记:访问时间、修改时间、状态改动时间
- linux查看文件按的精确的时间
- linux中touch命令参数修改文件的时间戳
- linux 使用 touch 修改文件的修改时间
- Linux系统下查看某文件修改的时间戳
- 在Linux下,一个文件也有三种时间,分别是:访问时间、修改时间、状态改动时间
- linux 使用 touch 修改文件的修改时间
- linux touch更改文件时间戳