Skip to content

起因

有时候环境上因为其他人修改了配置导致服务启动异常,可以确定的时候在某个时间点之后才出现的异常,那就需要找出修改的文件列表。

方案

我们都知道在 Linux 上,查找文件使用 find 命令。要找出在某个指定时间之后修改的文件列表可以以下使用命令

shell
find /path/to/directory -type f -newermt "2023-01-01 00:00:00"

如果要查找某个时间点之前修改的文件列表,可以加上 -not 参数

shell
find /path/to/directory -type f -not -newermt "2023-01-01 00:00:00"

如果是在 Windows 系统上,可以在 powershell 中执行以下命令查询最新修改的文件列表

shell
Get-ChildItem -Path "C:\path\to\directory" -Recurse | Where-Object { $_.LastWriteTime -ge "2022-03-01 00:00:00" }

Released under the MIT License.