根据列中的文本过滤行

cha*_*has 1 unix awk filter

我有一个制表符分隔的文本文件,如下所示:

27  1   hom het:het    het,het,het,het
18  1   hom het:het    hom,het,het,het,het,het,het
29  1   hom het:het    hom,hom,hom,hom,hom,hom,hom,hom,hom,hom,hom,hom,hom,hom
13  1   hom het:het    het,het,het,het,het,het
21  1   hom het:het    hom,het,het,het,het,het,hom,het,hom,het,het,het,hom
25  1   hom het:het    het,hom,het,het,het
29  1   hom het:het    hom,hom,het,hom,het,het,hom,het,het,hom,het,hom,het,hom
18  1   hom het:het    het,het,het
19  1   hom het:het    het,het,hom,het,het,het,het,het,het,hom,het,het,hom,het
Run Code Online (Sandbox Code Playgroud)

我想排除第5列中有'hom'的行.即输出应如下所示:

27  1   hom het:het    het,het,het,het
13  1   hom het:het    het,het,het,het,het,het
18  1   hom het:het    het,het,het
Run Code Online (Sandbox Code Playgroud)

使用unix命令的任何帮助?

Chr*_*our 5

Awk非常适合这个:

$ awk '$5!~/\<hom\>/' file
27  1   hom het:het    het,het,het,het
13  1   hom het:het    het,het,het,het,het,het
18  1   hom het:het    het,het,het
Run Code Online (Sandbox Code Playgroud)

说明:

$5         # is the fifth column
!~         # negated regex match 
/          # start regex string
\<         # matches the empty string at the beginning of a word.
hom        # matches the literal string 'hom'
\>         # matches the empty string at the end of a word.
/          # end regex string
Run Code Online (Sandbox Code Playgroud)