linux 中touch命令修改atime和mtime
1、测试数据
root@ubuntu01:/home/test# ls a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 14:27:12.494846760 +0800 Modify: 2022-02-01 12:30:00.000000000 +0800 Change: 2022-03-27 14:27:01.926886078 +0800 Birth: -
2、touch -a :atime更新到系统当前时间
root@ubuntu01:/home/test# ls a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 14:27:12.494846760 +0800 Modify: 2022-02-01 12:30:00.000000000 +0800 Change: 2022-03-27 14:27:01.926886078 +0800 Birth: - root@ubuntu01:/home/test# date 2022年 03月 27日 星期日 14:28:14 CST root@ubuntu01:/home/test# touch -a a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 14:28:20.006636889 +0800 Modify: 2022-02-01 12:30:00.000000000 +0800 Change: 2022-03-27 14:28:20.006636889 +0800 Birth: -
3、touch -m: mtime修改到当前时间
root@ubuntu01:/home/test# ls a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 14:28:20.006636889 +0800 Modify: 2022-02-01 12:30:00.000000000 +0800 Change: 2022-03-27 14:28:20.006636889 +0800 Birth: - root@ubuntu01:/home/test# date 2022年 03月 27日 星期日 14:29:31 CST root@ubuntu01:/home/test# touch -m a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 14:28:20.006636889 +0800 Modify: 2022-03-27 14:29:36.917365925 +0800 Change: 2022-03-27 14:29:36.917365925 +0800 Birth: -
3、touch -c:全部修改到当前时间
root@ubuntu01:/home/test# ls a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 14:30:48.772042772 +0800 Modify: 2022-03-27 14:29:36.917365925 +0800 Change: 2022-03-27 14:29:36.917365925 +0800 Birth: - root@ubuntu01:/home/test# date 2022年 03月 27日 星期日 14:32:17 CST root@ubuntu01:/home/test# touch -c a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 14:32:22.810687351 +0800 Modify: 2022-03-27 14:32:22.810687351 +0800 Change: 2022-03-27 14:32:22.810687351 +0800 Birth: -
4、touch -d “指定时间”
root@ubuntu01:/home/test# ls a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 14:34:12.697482322 +0800 Modify: 2022-03-27 14:34:53.213112565 +0800 Change: 2022-03-27 14:34:53.213112565 +0800 Birth: - root@ubuntu01:/home/test# date 2022年 03月 27日 星期日 14:35:24 CST root@ubuntu01:/home/test# touch -d "10:20" a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 10:20:00.000000000 +0800 Modify: 2022-03-27 10:20:00.000000000 +0800 Change: 2022-03-27 14:35:32.324785145 +0800 Birth: -
5、atime修改到指定时间
root@ubuntu01:/home/test# ls a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-03-27 10:20:00.000000000 +0800 Modify: 2022-03-27 10:20:00.000000000 +0800 Change: 2022-03-27 14:35:32.324785145 +0800 Birth: - root@ubuntu01:/home/test# touch -at 200910112200 a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2009-10-11 22:00:00.000000000 +0800 Modify: 2022-03-27 10:20:00.000000000 +0800 Change: 2022-03-27 14:41:18.442652519 +0800 Birth: -
6、mtime修改到指定时间
root@ubuntu01:/home/test# ls a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2009-10-11 22:00:00.000000000 +0800 Modify: 2022-03-27 10:20:00.000000000 +0800 Change: 2022-03-27 14:41:18.442652519 +0800 Birth: - root@ubuntu01:/home/test# touch -mt 201510101230 a.txt root@ubuntu01:/home/test# stat a.txt File: a.txt Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 532492 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2009-10-11 22:00:00.000000000 +0800 Modify: 2015-10-10 12:30:00.000000000 +0800 Change: 2022-03-27 14:43:20.338074499 +0800 Birth: -
如何只修改 ctime?
分类:
linux shell
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET10 - 预览版1新功能体验(一)
2021-03-27 c语言中输入数组元素的值