(十)修改档案时间与建置新档:touch
修改档案时间与建置新档:touch
写法:touch [-参数] 档案
参数:
-a :仅修订access time
-c : 仅修改时间,而不建立档案
-d:后面可以接日期,也可以使用--date=“日期或时间”
-m:仅修改mtime
-t:后面可以接时间,格式为[YYMMDDhhmm]
-r:把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同
实例一:创建不存在的文件(touch 123.log 456.log)
[root@localhost tmp]# touch 123.log 456.log //创建123.log 456log文件 [root@localhost tmp]# ll 总用量 4 -rw-r--r--. 1 root root 0 8月 28 00:53 123.log -rw-r--r--. 1 root root 0 8月 28 00:53 456.log drwxr-xr-x. 2 root root 4096 8月 11 23:02 asd srwxrwxrwx. 1 root root 0 8月 12 18:28 fcoemon.dcbd.1383 srwxrwxrwx. 1 root root 0 8月 28 00:32 fcoemon.dcbd.1522 -rw-r--r--. 1 root root 0 8月 28 00:46 testtouch -rw-------. 1 root root 0 8月 10 21:07 yum.log [root@localhost tmp]# touch -c 789.log //如果789.log不存在,则不建立文件 [root@localhost tmp]# ll 总用量 4 -rw-r--r--. 1 root root 0 8月 28 00:53 123.log -rw-r--r--. 1 root root 0 8月 28 00:53 456.log drwxr-xr-x. 2 root root 4096 8月 11 23:02 asd srwxrwxrwx. 1 root root 0 8月 12 18:28 fcoemon.dcbd.1383 srwxrwxrwx. 1 root root 0 8月 28 00:32 fcoemon.dcbd.1522 -rw-r--r--. 1 root root 0 8月 28 00:46 testtouch -rw-------. 1 root root 0 8月 10 21:07 yum.log
实例二:更新123.log的时间和456.log时间戳相同(touch -r 123.log 456.log)
[root@localhost tmp]# touch -r 123.log 456.log [root@localhost tmp]# ll 总用量 4 -rw-r--r--. 1 root root 0 8月 28 00:53 123.log -rw-r--r--. 1 root root 0 8月 28 00:53 456.log drwxr-xr-x. 2 root root 4096 8月 11 23:02 asd srwxrwxrwx. 1 root root 0 8月 12 18:28 fcoemon.dcbd.1383 srwxrwxrwx. 1 root root 0 8月 28 00:32 fcoemon.dcbd.1522 -rw-r--r--. 1 root root 0 8月 28 00:46 testtouch -rw-------. 1 root root 0 8月 10 21:07 yum.log
实例三:设定文件的时间戳(touch -t 201211142322 123.log)
[root@localhost tmp]# touch -t 201211142322 123.log [root@localhost tmp]# ll 总用量 4 -rw-r--r--. 1 root root 0 11月 14 2012 123.log -rw-r--r--. 1 root root 0 8月 28 00:53 456.log drwxr-xr-x. 2 root root 4096 8月 11 23:02 asd srwxrwxrwx. 1 root root 0 8月 12 18:28 fcoemon.dcbd.1383 srwxrwxrwx. 1 root root 0 8月 28 00:32 fcoemon.dcbd.1522 -rw-r--r--. 1 root root 0 8月 28 00:46 testtouch -rw-------. 1 root root 0 8月 10 21:07 yum.log
说明:
-t time 使用指定的时间值 time 作为指定文件相应时间戳记的新值.此处的 time规定为如下形式的十进制数:
[[CC]YY]MMDDhhmm[.SS]


浙公网安备 33010602011771号