gpt4 book ai didi

linux - 更改文件 Linux 上的更改时间戳

转载 作者:太空宇宙 更新时间:2023-11-04 11:58:59 25 4
gpt4 key购买 nike

因此,我尝试使用从此处获取的脚本更改文件的更改时间戳: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.

关于linux - 更改文件 Linux 上的更改时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53213926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com