更改符号链接的时间戳

amp*_*ent 36 rhel symlink timestamps

我知道如何更改常规文件的时间戳:

touch -t 201301291810 myfile.txt
Run Code Online (Sandbox Code Playgroud)

我无法用符号链接做同样的事情。是否可以?

发行版:RHEL 5.8

Ste*_*han 52

添加开关 -h

touch -h -t 201301291810 myfile.txt

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)
  -h, --no-dereference   affect each symbolic link instead of any referenced
                         file (useful only on systems that can change the
                         timestamps of a symlink)
  -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
Run Code Online (Sandbox Code Playgroud)

  • 查看引用“仅在可以更改符号链接时间戳的系统上有用”。 (3认同)
  • 它也是最近才添加的(它不在 [this manpage from 2010](http://man.he.net/?topic=touch§ion=1))。也许他只需要获取最新版本的coreutils。[这是 2009 年添加时的差异](http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=9e13b6a0b41532b63778aa67df40710df41174eb) (3认同)