Quantcast
Channel: E网的那些事儿 » linux
Viewing all articles
Browse latest Browse all 2

在linux中使用 touch命令批量修改文件时间

$
0
0

有时候因为服务器时间错了,需要更改文件的修改时间时间,可以使用 touch命令来修改文件的修改时间

touch -c -m -t 201101110000 readme.txt

修改readme.txt为2011年1月11日零时零分修改

如果批量修改文件和目录,则使用

 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://feed.feedsky.com/sinsky   转载请注明来源,喜欢本站可以Feed订阅本站。

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images