unix帮助grep?

时间:2010-11-23 15:18:48

标签: unix file recursion grep

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

4 个答案:

答案 0 :(得分:3)

请参阅find,尤其是谓词-anewer-atime-mtime-newer-newerXY

答案 1 :(得分:1)

您可以将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 {} +

答案 2 :(得分:0)

可能像

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

让你入门?

答案 3 :(得分:0)

最容易使用的是zsh。 Beats发现任何一天的简单性和性能。

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

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