可以使用 'touch' 命令来修改文件或文件夹的时间戳。如果要修改一个文件夹中的所有文件的时间戳,可以使用以下命令:

touch -r '/path/to/reference/file' '/path/to/folder/*'

其中,'/path/to/reference/file' 是一个已存在的文件,可以是文件夹中的任意一个文件,用于参考时间戳。'/path/to/folder/*' 表示需要修改时间戳的文件夹中所有文件。

例如,如果要将 '/home/user/documents' 文件夹中所有文件的时间戳修改为 '/home/user/documents/reference.txt' 文件的时间戳,可以使用以下命令:

touch -r '/home/user/documents/reference.txt' '/home/user/documents/*'

执行完毕后,所有文件的时间戳都会被修改为 'reference.txt' 文件的时间戳。

Ubuntu 修改文件夹内所有文件时间戳 - 使用 touch 命令

原文地址: https://www.cveoy.top/t/topic/jzDp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录