linux - 编写linux脚本将1970年1月1日之前的时间戳转换为1970年2月2日

标签 linux shell date timestamp

我无法将我的文件与 Owncloud 同步,因为某些时间戳早于 1.1.1970(Unix 开始时间约定)。

有人知道如何编写一个脚本来查找时间戳早于 1970 年 1 月 1 日的所有文件,并将它们转换为 1970 年 1 月 1 日之后的任何日期,也许是 1980 年 1 月 1 日?

谢谢

最佳

最佳答案

你可以试试这个(在GNU/Linux系统上测试过)

touch -d "1970-01-01 00:00:00" /tmp/timestamp
find / -not -cnewer /tmp/timestamp -exec touch {} \;

这是与 POSIX.1 兼容的版本:

touch -d "1970-01-01 00:00:00" /tmp/timestamp
find / ! -newer /tmp/timestamp -exec touch {} \;

参见touchfind .

关于linux - 编写linux脚本将1970年1月1日之前的时间戳转换为1970年2月2日,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22453590/

相关文章:

java - 我如何反序列化字符串 Json Date?

java - 如何在 GWT 中使用时区解析日期字符串

linux - bash 脚本需要读取用户输入并将其用作另一个命令的参数

linux - 在 Linux 上将 AVI 帧转换为 JPG

c++ - 如何替换 operator new/delete 而不干扰库?

linux - 在 linux 中读取文件

linux - 如何在 ImageMagick 中使用带有标题的标准输入

linux - 为什么在运行 bash 脚本时出现意外的文件结束错误?

python - 如何使用 python 更改用户的 shell 当前目录? (Ubuntu/Linux)

javascript - 在一年的最后一周添加 1 周时出现 Moment.js 错误