因此,我尝试使用从此处获取的脚本更改文件的更改时间戳:Setting/changing the ctime or "Change time" attribute on a file
#!/bin/sh
now=$(date)
echo $now
sudo date --set="qui nov 7 21:05:56 WET 2018"
chmod 777 $1
sudo date --set="$now"
这是输出:
qui nov 8 18:19:39 WET 2018
date: invalid date ‘qui nov 7 21:05:56 WET 2018’
date: invalid date ‘qui nov 8 18:19:39 WET 2018’
怎么了? date 的输出不是有效日期?我尝试了对我链接的答案的评论中建议的修复,但它也不起作用。
AFAIK 争论不同的原因:
$ info date
Invoking 'date' with no FORMAT argument is equivalent to invoking it
with a default format that depends on the 'LC_TIME' locale category.
在设置时间
下:
If given an argument that does not start with '+', 'date' sets the
system clock to the date and time specified by that argument (as
described below). You must have appropriate privileges to set the
system clock. Note for changes to persist across a reboot, the hardware
clock may need to be updated from the system clock, which might not
happen automatically on your system.
The argument must consist entirely of digits, which have the
following meaning:
'MM'
month
'DD'
day within month
'hh'
hour
'mm'
minute
'CC'
first two digits of year (optional)
'YY'
last two digits of year (optional)
'ss'
second (optional)
Note, the '--date' and '--set' options may not be used with an
argument in the above format. The '--universal' option may be used with
such an argument to indicate that the specified date and time are
relative to Coordinated Universal Time rather than to the local time
zone.
我是一名优秀的程序员,十分优秀!