unix对grep的帮助?
(无论如何,我想我可以使用grep…)尝试递归地列出在特定日期修改的文件,但是,我尝试使用的命令要么列出按日期排序的所有文件,要么只列出我所在目录中的文件。有办法做到这一点吗?是grep还是别的什么?参见,特别是谓词unix对grep的帮助?,unix,file,recursion,grep,Unix,File,Recursion,Grep,(无论如何,我想我可以使用grep…)尝试递归地列出在特定日期修改的文件,但是,我尝试使用的命令要么列出按日期排序的所有文件,要么只列出我所在目录中的文件。有办法做到这一点吗?是grep还是别的什么?参见,特别是谓词-anewer,-atime,-mtime,-newer和-newerXY参见,特别是谓词-anewer,-atime,-mtime>,-mtime,-newer和-newerXY可能类似 find . -type f -exec ls -l \{\} \; | grep " Aug
-anewer
,-atime
,-mtime
,-newer
和-newerXY参见,特别是谓词-anewer
,-atime
,-mtime>,-mtime
,-newer
和-newerXY
可能类似
find . -type f -exec ls -l \{\} \; | grep " Aug 26 2003"
开始吧?可能是这样的
find . -type f -exec ls -l \{\} \; | grep " Aug 26 2003"
开始吗?您可以将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 {} +
您可以将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 {} +
最容易使用的是zsh。Beats在任何一天都能发现简单性和性能
ls**/*(m5)
将递归列出恰好在5天前修改的文件<代码>ls**/*(mh-5)
将列出过去5小时内修改的文件。您可以根据需要选择月、日、时、分、秒。如果需要,您可以要求N天前访问的文件,而不是修改时间
当然,该命令不必是ls。您需要做的任何事情都可以。最容易使用的是zsh。Beats在任何一天都能发现简单性和性能
ls**/*(m5)
将递归列出恰好在5天前修改的文件<代码>ls**/*(mh-5)
将列出过去5小时内修改的文件。您可以根据需要选择月、日、时、分、秒。如果需要,您可以要求N天前访问的文件,而不是修改时间
当然,该命令不必是ls。你需要做的任何事都可以