场景:文件夹中有多个文件,我正在尝试查找特定的文件集,如果给定的文件有特定的信息,那么我需要grep信息.
例如:
find /abc/test \( -type f -name 'tst*.txt' -mtime -1 \) -exec grep -Po '(?<type1).*(?=type1|(?<=type2).*(?=type2)' {} \;
Run Code Online (Sandbox Code Playgroud)
我需要包括if条件和find -exec(如果grep为true则打印上面的内容)
if grep -q 'case=1' <filename>; then
grep -Po '(?<type1).*(?=type1|(?<=type2).*(?=type2)'
fi
Run Code Online (Sandbox Code Playgroud)
谢谢