touch [选项]... 文件名...shell
建立文件,修改时间戳spa
-r 设置文档的时间戳为指定文件或者目录的时间戳code
-t 设置文档的时间戳为指定的时间,而非系统时间,时间戳格式为 YYYYMMDDhhmm.SSorm
1:建立一个文件文档
[root@master120 temp]# touch hehe.txt [root@master120 temp]# ll total 0 -rw-r--r-- 1 root root 0 Aug 14 14:10 hehe.txt
2:建立一堆文件,若是有的文件已存在,就改一下时间戳ast
[root@master120 temp]# touch hehe.txt haha.txt [root@master120 temp]# ll total 0 -rw-r--r-- 1 root root 0 Aug 14 14:11 haha.txt -rw-r--r-- 1 root root 0 Aug 14 14:11 hehe.txt
3:设置文档的时间戳为指定文件或者目录的时间戳class
[root@master120 temp]# touch -r hehe.txt haha.txt
4:设定时间戳为指定的时间时间戳
[root@master120 temp]# touch -t 201408131455.55 hehe.txt [root@master120 temp]# ll total 0 -rw-r--r-- 1 root root 0 Aug 14 14:11 haha.txt -rw-r--r-- 1 root root 0 Aug 13 14:55 hehe.txt