【发布时间】:2019-02-20 15:35:42
【问题描述】:
我想获取当前目录或任何子目录中所有文件的列表,其中包含按修改日期排序的某个字符串。
我无法得到答案
How to sort the output of "grep -l" chronologically by newest modification date last?
用于递归 grep 搜索。如何获得这样一个有序列表,以便真正包含 grep -lr 找到的所有文件。
【问题讨论】:
我想获取当前目录或任何子目录中所有文件的列表,其中包含按修改日期排序的某个字符串。
我无法得到答案
How to sort the output of "grep -l" chronologically by newest modification date last?
用于递归 grep 搜索。如何获得这样一个有序列表,以便真正包含 grep -lr 找到的所有文件。
【问题讨论】:
假设您的文件名不包含换行符:
find dir -type f -printf '%T@\t%p\n' | sort | cut -f2- | xargs grep -l whatever
更稳健地使用 GNU 版本的工具来处理包含外来字符的目录/文件名:
find dir -type f -printf '%T@\t%p\0' | sort -z | cut -z -f2- | xargs -0 grep -l whatever
【讨论】: