(我想我可以使用grep,无论如何....)试图递归列出在特定日期修改的文件,但是,我尝试使用的命令列出按日期排序的所有内容,或者只列出目录中的列表文件我在。有没有办法做到这一点?是grep还是其他什么?
答案 0 :(得分:3)
请参阅find
,尤其是谓词-anewer
,-atime
,-mtime
,-newer
和-newerXY
。
答案 1 :(得分:1)
您可以将ls
和grep
合并为递归列表文件,然后搜索特定日期。
# 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。你需要做的任何事情都可以。