找到与给定模式不匹配的行

时间:2022-04-01 21:25:26

I have a large file and I want to print the lines that do not match a particular undesired pattern. The following does the exact opposite of what I want, namely it retains all the undesirable lines.

我有一个大文件,我想打印与特定不需要的模式不匹配的行。以下与我想要的完全相反,即它保留了所有不需要的行。

grep -e '\[0.0, 0.0\]' locscore.txt

How can I get the lines that DON'T have the above pattern? I tried

如何获得不具有上述模式的线条?我试过了

grep -e '^*(?!\[0.0, 0.0\])*$' locscore.txt

but it produces nothing.

但它什么都没产生。

1 个解决方案

#1


3  

if you use grep, there is an option -v, it does what you need.

如果你使用grep,有一个选项-v,它可以满足你的需要。

from man page:

来自手册页:

  -v, --invert-match
              Invert the sense of matching, to select non-matching lines.  (-v is specified by POSIX.)

#1


3  

if you use grep, there is an option -v, it does what you need.

如果你使用grep,有一个选项-v,它可以满足你的需要。

from man page:

来自手册页:

  -v, --invert-match
              Invert the sense of matching, to select non-matching lines.  (-v is specified by POSIX.)