【发布时间】:2016-04-27 19:54:47
【问题描述】:
场景:一个文件夹中有多个文件,我正在尝试查找特定的文件集,如果给定文件具有特定信息,那么我需要 grep 信息。
例如:
find /abc/test \( -type f -name 'tst*.txt' -mtime -1 \) -exec grep -Po '(?<type1).*(?=type1|(?<=type2).*(?=type2)' {} \;
我需要在 find -exec 中包含 if 条件(如果 grep 为真,则打印以上内容)
if grep -q 'case=1' <filename>; then
grep -Po '(?<type1).*(?=type1|(?<=type2).*(?=type2)'
fi
谢谢
【问题讨论】:
-
所以需要单独处理每个文件?