找到不符合给定模式的线条 [英] finding lines that Don't match a given pattern

查看:103
本文介绍了找到不符合给定模式的线条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大文件,我想打印不符合特定不希望模式的行。以下做的和我想要的完全相反,即它保留了所有不需要的行。

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

如何获取不具有的行上述模式?
我试过了

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

但它什么也没有产生。

解决方案

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

从手册页:

  -v,--invert-match 
颠倒匹配的意义,选择不匹配的行。 (-v由POSIX指定)


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.

解决方案

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

from man page:

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

这篇关于找到不符合给定模式的线条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆