简体   繁体   English

查找过去 24 小时内更改过的文件

[英]Find the files that have been changed in last 24 hours

Eg, a MySQL server is running on my Ubuntu machine.例如,MySQL 服务器正在我的 Ubuntu 机器上运行。 Some data has been changed during the last 24 hours.在过去 24 小时内,某些数据已更改。

What (Linux) scripts can find the files that have been changed during the last 24 hours?哪些 (Linux) 脚本可以找到过去 24 小时内已更改的文件?

Please list the file names, file sizes, and modified time.请列出文件名、文件大小和修改时间。

To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:要在特定特定目录及其子目录中查找过去 24 小时(最后一整天)内修改的所有文件:

find /directory_path -mtime -1 -ls

Should be to your liking应该是你喜欢的

The - before 1 is important - it means anything changed one day or less ago. - before 1很重要 - 这意味着在一天或更短时间内发生了任何变化。 A + before 1 would instead mean anything changed at least one day ago, while having nothing before the 1 would have meant it was changed exacted one day ago, no more, no less.相反, 1之前的+表示至少一天前发生了任何变化,而在1之前没有任何内容则意味着它在一天前被严格更改,不多也不少。

Another, more humane way:另一种更人性化的方式:

find /<directory> -newermt "-24 hours" -ls

or:或者:

find /<directory> -newermt "1 day ago" -ls

or:或者:

find /<directory> -newermt "yesterday" -ls

You can do that with你可以这样做

find . -mtime 0

From man find :man find

[The] time since each file was last modified is divided by 24 hours and any remainder is discarded. [The] 自上次修改每个文件以来的时间除以 24 小时,其余的将被丢弃。 That means that to match -mtime 0, a file will have to have a modification in the past which is less than 24 hours ago.这意味着要匹配 -mtime 0,文件必须在过去不到 24 小时前进行过修改。

On GNU-compatible systems (ie Linux):在 GNU 兼容系统(即 Linux)上:

find . -mtime 0 -printf '%T+\t%s\t%p\n' 2>/dev/null | sort -r | more

This will list files and directories that have been modified in the last 24 hours ( -mtime 0 ).这将列出在过去 24 小时内修改过的文件和目录( -mtime 0 )。 It will list them with the last modified time in a format that is both sortable and human-readable ( %T+ ), followed by the file size ( %s ), followed by the full filename ( %p ), each separated by tabs ( \t ).它将以可排序和人类可读的格式( %T+ )列出它们以及最后修改时间,然后是文件大小( %s ),然后是完整文件名( %p ),每个都用制表符分隔( \t )。

2>/dev/null throws away any stderr output, so that error messages don't muddy the waters; 2>/dev/null丢弃任何 stderr 输出,这样错误消息就不会混淆; sort -r sorts the results by most recently modified first; sort -r按最近修改的优先排序结果; and | more| more | more lists one page of results at a time. | more一次列出一页结果。

对于将来登陆这里的其他人(包括我自己),添加 -name 选项以查找特定文件类型,例如: find /var -name "*.php" -mtime -1 -ls

这个命令对我有用

find . -mtime -1 -print

Find the files...找到文件...

You can set type f = file您可以设置类型 f = 文件

find /directory_path -type f -mtime -1 -exec ls -lh {} \;

👍 👍

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 复制过去24小时内容已更改的特定命名目录 - Copy specific named directories which content changed the last 24 hours Linux-如何查找最近12个小时内未查找命令更改的文件 - Linux - How to find files changed in last 12 hours without find command 如何获取存储库中在过去 6 个月内未更新/更改的文件列表 - How to get the list of files in a repository that have not been updated/changed in the last 6 months Bash脚本查找过去24小时内最近修改的大文件 - Bash Script to find large files recently modified in the past 24 hours 修改 atime 以检查文件是否在过去 24 小时内被修改过 - modifying atime to check if file has been modified within last 24 hours 将二进制文件与导出的文本文件进行比较,找出哪些二进制文件已更改或自上次导出以来是下一个 - Compare binary to exported textfiles and find which binary files have changed or are next since last export 如何在 GCP 控制台中使用 gsutil 下载过去 24 小时内创建的文件? - How to download files which are created in last 24 hours using gsutil in GCP console? 以bash格式表示最近24小时的grep时间戳 - Grep timestamp for last 24 hours in bash 复制24小时内在Unix中生成的文件 - Copy files in Unix generated in 24 hours 复制/停止过去14天内修改过的文件 - Copying / Tarring Files that have been modified in the last 14 days
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM