linux 使用 touch 修改文件的修改时间
https://www.akii.org/linux-touch-change-file-modify-time.html
rsync有時(shí)候因?yàn)榉?wù)器時(shí)間錯(cuò)了,需要更改文件的修改時(shí)間時(shí)間,可以使用 touch命令來修改文件的修改時(shí)間:
| 1 | touch -c -m -t 201101110000 teadme.txt | 
修改readme.txt為2011年1月11日零時(shí)零分修改
如果批量修改文件和目錄,則使用
| 1 | find /home/www/site -exec touch -c -m -t 201101110000 {} \; | 
即可把/home/www/site下的所有文件和目錄都改變修改時(shí)間。
注意上面命令中的空格。
touch [-acdmt] 文件參數(shù):
-a : 僅修改access time。
-c : 僅修改時(shí)間,而不建立文件。
-d : 后面可以接日期,也可以使用 –date=”日期或時(shí)間”
-m : 僅修改mtime。
-t : 后面可以接時(shí)間,格式為 [YYMMDDhhmm]
如 touch -c -t 0906270730 file
Usage: touch [OPTION]… FILE…
 Update the access and modification times of each FILE to the current time.
Mandatory arguments to long options are mandatory for short options too.
 -a change only the access time
 -c, –no-create do not create any files
 -d, –date=STRING parse STRING and use it instead of current time
 -f (ignored)
 -m change only the modification time
 -r, –reference=FILE use this file’s times instead of current time
 -t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time
 –time=WORD change the specified time:
 WORD is access, atime, or use: equivalent to -a
 WORD is modify or mtime: equivalent to -m
 –help display this help and exit
 –version output version information and exit
Note that the -d and -t options accept different time-date formats.
If a FILE is -, touch standard output.
?
總結(jié)
以上是生活随笔為你收集整理的linux 使用 touch 修改文件的修改时间的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: linux rm命令参数及用法详解---
- 下一篇: Java Annotation详解
