linux中如何使用touch修改文件的修改时间
rsync有时候因为服务器时间错了,需要更改文件的修改时间时间,可以使用 touch命令来修改文件的修改时间: 1 touch -c -m -t 201101110000 teadme.txt 修改readme.txt为2011年1月11日零时零分修改 如果批量修改文件和目录,则使用 1 find /home/www/site -exec touch -c -m -t 201101110000 {} ; 即可把/home/www/site下的所有文件和目录都改变修改时间。 注意上面命令中的空格。 touch [-acdmt] 文件参数: -a : 仅修改access time。 -c : 仅修改时间,而不建立文件。 -d : 后面可以接日期,也可以使用 –date=”日期或时间” -m : 仅修改mtime。 -t : 后面可以接时间,格式为 [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. 查看本栏目更多精彩内容:http://www.bianceng.cn/OS/Linux/ (编辑:佛山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |