如何过滤巨大的日志文件?

如何过滤巨大的日志文件?

我有数据

15:29:05:493582: Impact Cost :Current[0.20] Required[5.00] Bid[price:3195 qty:450] Ask[price:3215 qty:600].
15:29:05:480193: Impact Cost :Current[0.15] Required[5.00] Bid[price:3195 qty:450] Ask[price:3210 qty:75].
15:29:05:462943: Impact Cost :Current[0.20] Required[5.00] Bid[price:3195 qty:450] Ask[price:3215 qty:600].
15:29:05:462886: Impact Cost :Current[0.20] Required[5.00] Bid[price:3195 qty:450] Ask[price:3215 qty:600].
15:29:05:462789: Impact Cost :Current[0.20] Required[5.00] Bid[price:3195 qty:450] Ask[price:3215 qty:600].
15:29:05:447389: Impact Cost :Current[0.15] Required[5.00] Bid[price:3195 qty:450] Ask[price:3210 qty:75].
15:29:05:446545: Impact Cost :Current[0.20] Required[5.00] Bid[price:3195 qty:450] Ask[price:3215 qty:600].
15:29:05:446381: Impact Cost :Current[0.20] Required[5.00] Bid[price:3195 qty:525] Ask[price:3215 qty:600].
15:29:05:409039: Impact Cost :Current[0.20] Required[5.00] Bid[price:3195 qty:75] Ask[price:3215 qty:600].
15:29:05:409019: Impact Cost :Current[0.20] Required[5.00] Bid[price:3195 qty:75] Ask[price:3215 qty:600].

我想输出为

Bid[price:3195 qty:450] Ask[price:3215 qty:600].
Bid[price:3195 qty:450] Ask[price:3210 qty:75].
Bid[price:3195 qty:450] Ask[price:3215 qty:600].
Bid[price:3195 qty:450] Ask[price:3215 qty:600].
Bid[price:3195 qty:450] Ask[price:3215 qty:600].
Bid[price:3195 qty:450] Ask[price:3210 qty:75].
Bid[price:3195 qty:450] Ask[price:3215 qty:600].
Bid[price:3195 qty:525] Ask[price:3215 qty:600].
Bid[price:3195 qty:75] Ask[price:3215 qty:600].
Bid[price:3195 qty:75] Ask[price:3215 qty:600].

请告诉我如何使用终端从 .txt 文件中提取它。

答案1

不需要正则表达式引擎的解决方案:

$ cut -d ' ' -f 6- logfile

在这种情况下,该cut实用程序将为您提供从第六列开始的所有列。它将把每行上的每个空格视为列分隔符。

答案2

这可能是一个非常简单的问题。如果您只想从“Bid”一词开始到行尾,您可以使用:

grep -o 'Bid.*' yourfile.txt

答案3

awk

awk '{ print $6$7$8$9 }' logfile

相关内容