试试这 3 个grep变体:
grep -l 'this is sentence\|another different sentence' *log
grep -lE 'this is sentence|another different sentence' *log
grep -lE '(this is sentence|another different sentence)' *log
如果要查找匹配的文件,-L
是不是正确的开关;而是使用-l
, from man grep
:
-L, --files-without-match
Suppress normal output; instead print the name of each input file
from which no output would normally have been printed. The scanning will
stop on the first match.
-l, --files-with-matches
Suppress normal output; instead print the name of each input file from which
output would normally have been printed. The scanning will stop on the first
match. (-l is specified by POSIX.)