如何在这个文本文件中grep或awk与我需要的内容相对应?

时间:2014-12-04 00:06:50

标签: awk grep

嘿所以我有一个包含所有这些字节的日志文件。 我只想grep或awk每行超过499的行并将其放入文本文件中。

这是一个例子。

Wed Dec  3 12:52:05 2014; UDP; eth1; 32 bytes; from 197.46.140.50:1434
Wed Dec  3 12:52:05 2014; UDP; eth1; 32 bytes; from 197.46.140.50:1434
Wed Dec  3 12:52:05 2014; UDP; eth1; 652 bytes; from 197.46.140.50:1434 
Wed Dec  3 12:52:05 2014; UDP; eth1; 32 bytes; from 197.46.140.50:1434 
Wed Dec  3 12:52:05 2014; UDP; eth1; 32 bytes; from 197.46.140.50:1434 
Wed Dec  3 12:52:05 2014; UDP; eth1; 122 bytes; from 197.46.140.50:1434
Wed Dec  3 12:52:05 2014; UDP; eth1; 32 bytes; from 197.46.140.50:1434
Wed Dec  3 12:52:05 2014; UDP; eth1; 32 bytes; from 197.46.140.50:1434 
Wed Dec  3 12:52:05 2014; UDP; eth1; 885 bytes; from 197.46.140.50:1434 

我只想要

Wed Dec  3 12:52:05 2014; UDP; eth1; 885 bytes; from 197.46.140.50:1434 
Wed Dec  3 12:52:05 2014; UDP; eth1; 652 bytes; from 197.46.140.50:1434 

放入文本文件。任何超过499字节的东西。

1 个答案:

答案 0 :(得分:4)

尝试这样做:

$ awk '$8 > 499' file > another_text_file

无需添加printawk已在TRUE条件下打印。

grep不是正确的工具。

相关问题