Sli*_*nky 9 linux grep regular-expressions
我有一个命令可以找到所有包含字符串“Font”的 PDF 文件
find /Users/me/PDFFiles/ -type f -name "*.pdf" -exec grep -H 'Font' '{}' ';'
Run Code Online (Sandbox Code Playgroud)
如何更改此命令以使其相反?查找所有不包含搜索字符串“字体”的 PDF 文件
cjc*_*cjc 19
你想使用“-L”选项grep
:
-L, --files-without-match
Only the names of files not containing selected lines are written to standard output. Path-
names are listed once per file searched. If the standard input is searched, the string
``(standard input)'' is written.
Run Code Online (Sandbox Code Playgroud)
只需添加“L”标志。这是相反的
find /Users/me/PDFFiles/ -type f -name "*.pdf" -exec grep -HL 'Font' '{}' ';'
Run Code Online (Sandbox Code Playgroud)