grep 列表反转
grep list invert
如果文件不包含字符串,如何打印文件名?
grep -vl 'string' file
总是打印 file
,我猜是因为每个文件至少有一行不是 string
.
$ ls
one two three four five
$ grep -l 'odd' *
one
three
five
$ grep -lv 'odd' *
one
two
three
four
five
但我希望它打印第一个选项的反函数
two
four
-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 of each file stops on the first match.
所以,你需要使用
grep -L 'odd' *
four
two
如果文件不包含字符串,如何打印文件名?
grep -vl 'string' file
总是打印 file
,我猜是因为每个文件至少有一行不是 string
.
$ ls
one two three four five
$ grep -l 'odd' *
one
three
five
$ grep -lv 'odd' *
one
two
three
four
five
但我希望它打印第一个选项的反函数
two
four
-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 of each file stops on the first match.
所以,你需要使用
grep -L 'odd' *
four
two