unix 帮助 grep 吗?

发布于 2024-10-03 15:39:14 字数 114 浏览 2 评论 0原文

(我想我可以使用 grep,无论如何......)尝试递归地列出在特定日期修改的文件,但是,我尝试使用的命令要么列出按日期排序的所有内容,要么只列出我所在目录中的文件有办法做到这一点吗?是 grep 还是其他什么?

(I think I can use grep, anyway....) Trying to recursively list files modified on a specific date, but, the commands I try to use either list everything sorted by date, or only list files in the directory that I'm in. Is there a way to do this? Is it grep or something else?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

酸甜透明夹心 2024-10-10 15:39:14

请参阅 find,特别是谓词 -anewer-atime-mtime-newer-newerXY

See find, particularly the predicates -anewer, -atime, -mtime, -newer and -newerXY.

木落 2024-10-10 15:39:14

您可以结合 lsgrep 递归地列出文件,然后搜索特定日期。

# List files recursively with `-R` and grep for a date.
ls -lR | grep 'Nov 23'

find 可用于递归查找与您选择的条件匹配的文件。然后它可以显示这些文件名,或将它们传递给另一个命令或任意数量的操作。

# Display all files modified yesterday.
find -mtime 0

# Display all files modified yesterday in `ls -l' format.
find -mtime 0 -ls

# Search all files modified yesterday for the string "foobar".
# "{}" is a placeholder for the file names and "+" tells find to
# pass all the files at once to a single invocation of grep.
find -mtime 0 -exec grep foobar {} +

You could combine ls and grep to list files recursively and then search for particular dates.

# List files recursively with `-R` and grep for a date.
ls -lR | grep 'Nov 23'

find can be used to recursively find files matching the criteria of your choice. It can then display these file names, or pass them to another command, or any number of actions.

# Display all files modified yesterday.
find -mtime 0

# Display all files modified yesterday in `ls -l' format.
find -mtime 0 -ls

# Search all files modified yesterday for the string "foobar".
# "{}" is a placeholder for the file names and "+" tells find to
# pass all the files at once to a single invocation of grep.
find -mtime 0 -exec grep foobar {} +
抚你发端 2024-10-10 15:39:14

可以

find . -type f -exec ls -l \{\} \; | grep " Aug 26  2003"

让你开始吗?

May something like

find . -type f -exec ls -l \{\} \; | grep " Aug 26  2003"

get you started?

蒗幽 2024-10-10 15:39:14

最容易使用的是 zsh。 Beats 每天都能感受到简单性和性能。

ls **/*(m5) 将递归列出 5 天前修改的文件。 ls **/*(mh-5) 将列出过去 5 小时内修改的文件。您可以根据需要选择月、日、小时、分钟、秒。如果需要,您可以询问 N 天前访问过的文件,而不是修改时间。

当然命令不一定是ls。任何你需要做的事情都会做。

Easiest to use is zsh. Beats find any day simplicity and performance-wise.

ls **/*(m5) will recursively list files modified exactly 5 days ago. ls **/*(mh-5) will list files modifed within the last 5 hours. You can select months, days, hours, minutes, seconds, as you wish. You can ask for files accessed N days ago instead of modification time if you need to.

Of course the command does not have to be ls. Anything you need to do will do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文