Touch命令
touch介绍
将每个文件的访问和修改时间更新为当前时间。除非提供-c或-h,否者将不存在的FILE参数创建为空
touch参数格式
touch [OPTION] ... FILE
touch命令参数
参数 | 释义 |
-a 或--time=atime或 --time=access或 --time=use |
只更改存取时间 |
-c或--no-create | 不建立任何文档 |
-d | 使用指定的日期时间,而非现在的时间 |
-f | 此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容行性问题。 |
-m或--time=mtime 或--time=modify |
只更改变动时间 |
-r | 把指定文档或目录的日期时间,统统设成和参考文档或目录的时间相同 |
-t | 使用指定的日期时间,而非现在的时间 |
touch用法示例
# touch test1 test2 test3 //创建三个测试文件 # touch -c test4 // 不创建文档 # ls //我们能可以看到 只有我们一开始创建的三个测试文件 test1 test2 test3 touch -t 202001060000 test1 # stat test* //stat可以查看文件的详细变更时间 File: ‘test1’ Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fd00h/64768d Inode: 326740 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-01-06 00:00:00.000000000 +0800 Modify: 2020-01-06 00:00:00.000000000 +0800 Change: 2020-01-07 00:40:04.916746826 +0800 Birth: - File: ‘test2’ Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fd00h/64768d Inode: 326741 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-01-07 00:38:36.672750610 +0800 Modify: 2020-01-07 00:38:36.672750610 +0800 Change: 2020-01-07 00:38:36.672750610 +0800 Birth: - File: ‘test3’ Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fd00h/64768d Inode: 326742 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-01-07 00:38:36.672750610 +0800 Modify: 2020-01-07 00:38:36.672750610 +0800 Change: 2020-01-07 00:38:36.672750610 +0800 Birth: -