多学一点(九)——使用touch命令创建指定时间的文件
2015-07-21 20:48
405 查看
之前在讲 find 命令时提到过其-newer , -anewer 和 -cnewer 参数,可以用这些参数查找某个时间段内的文件。但往往我们没有两个想要使用的准确的时间节点文件,这就需要用到接下来要介绍的用 touch 命令创建指定 atime 、 mtime 的文件。 (1)-t 参数:指定文件atime 和 mtime,可以使用 1970年1月1日到指定日期的毫秒数,也可以直接使用日期,格式为 [[CC]YY]MMDDhhmm[.ss]:[root@localhost ~]# touch -t 201003141036.30 oldfile注意这里的时间也可以使用引号引上,即:[root@localhost ~]# touch -t "201003141036.30" oldfile(2)-d 参数:与 -t 参数的作用相同,指定文件 atime 和 mtime,只是使用格式略有区别,使用字符串形式来指定时间:[root@localhost ~]# touch -d "20020306"[root@localhost ~]# touch -d "20020304 12:38"(3)-r 参数:使用其他文件的atime 和 mtime 作为该文件的atime 和 mtime:[root@localhost ~]# touch -r oldfile newfile(4)-a 参数:只修改atime ,对时间的设置不会影响到 mtime ,结合-d 或 -t 或 -r 使用:[root@localhost ~]# touch -a -t 201003141036.30 oldfile[root@localhost ~]# touch -r oldfile newfile -a(5)-m 参数:只修改mtime,对时间的设置不会影响到 atime ,结合-d 或 -t 或 -r使用:[root@localhost ~]# touch -m -t 201003141036.30 oldfile[root@localhost ~]# touch -r oldfile newfile -m注:touch 没有相关参数来指定文件 ctime,即新创建的文件的 ctime 只能为当前时间。
本文出自 “细桶假狗屎” 博客,请务必保留此出处http://xitongjiagoushi.blog.51cto.com/9975742/1632840
本文出自 “细桶假狗屎” 博客,请务必保留此出处http://xitongjiagoushi.blog.51cto.com/9975742/1632840
相关文章推荐
- 学习笔记(十一)——Linux Shell 基础知识
- 多学一点(八)——LNMP环境搭建
- NSString
- 多学一点(五)——在Linux下安装配置Apache
- 多学一点(六)——在Linux下安装配置MySQL
- 多学一点(七)——不重启Linux添加磁盘,使用软链接为挂载点扩容
- 暑假集训第二周——贪心 L - 生物碰撞
- 使用express4.x版和Jade模板重写《nodejs开发指南》微博实例
- 使用 .gitignore来忽略某些文件
- A + B for you again(KMP)
- Java Web开发【3】对【1】【2】中代码的修改
- 关于java基础--面向对象的特性
- 学习笔记(九)——压缩和打包
- 习题总结(二)——禁ctrl+alt+delete,禁普通用户登录,禁ping
- 多学一点(四)——在 Linux 下配置多个 Tomcat
- 多学一点(三)——find 命令详解
- 多学一点(二)——在 Linux 下挂载 Windows 共享目录、使用 scp 命令在两台 Linux 间传输数据
- 学习笔记(七)——Linux 磁盘管理
- 习题总结(一)——硬链接,locate,chmod,家目录
- 多学一点(一)——在 Linux 下安装 JDK 和 Tomcat