linux命令---touch
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux命令---touch相关的知识,希望对你有一定的参考价值。
touch: change file timestamps 更改文件时间戳
常用选项:
-a 更改文件的访问时间为当前时间
-m 更改文件的修改内容时间为当前时间
-c 更改文件的ctime时间为当前时间,即修改文件的属性与权限时间
实例:
[[email protected] ~]# touch a.txt #创建空文件,常用
[[email protected] ~]# ls -l a.txt
-rw-r--r--. 1 root root 0 Aug 26 05:30 a.txt
[[email protected] ~]# ls -l --time=atime test.txt #访问时间
-rw-r--r--. 1 root root 610 Aug 26 05:01 test.txt
[[email protected] ~]# ls -l --time=ctime test.txt #修改属性与权限时间
-rw-r--r--. 1 root root 610 Aug 23 05:04 test.txt
[[email protected] ~]# ls -l test.txt #更改文件内容的时间
-rw-r--r--. 1 root root 610 Aug 23 05:04 test.txt
[[email protected] ~]# touch -a test.txt #更改文件的访问时间为当前时间
[[email protected] ~]# ll --time=atime test.txt
-rw-r--r--. 1 root root 610 Aug 26 05:26 test.txt
[[email protected] ~]# touch -m test.txt #更改文件修改内容的时间
[[email protected] ~]# ll test.txt
-rw-r--r--. 1 root root 610 Aug 26 05:29 test.txt
以上是关于linux命令---touch的主要内容,如果未能解决你的问题,请参考以下文章