使用grep解析股票,价格在列格式修复日志/ AWK / UNIX [英] Parsing fix logs for stock and price in column formats using grep /awk/UNIX
本文介绍了使用grep解析股票,价格在列格式修复日志/ AWK / UNIX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含交易信息的修复记录,如:
I have a fix log containing trade information such as:
==> 8=FIX4.2|39=1|55=IBM|6=138
==> 8=FIX4.2|39=1|55=APPL|6=130
==> 8=FIX4.2|39=1|55=GE|6=11
我试图到grep的输出,这样我可以得到的东西是这样的:
I'm trying to grep the output so that i can get something like this:
IBM 138
APPL 130
GE 11
其中第一列是IBM和第二列是138
where the first column is IBM and the second column is 138.
我想这样的:
grep 39=1 some.log | tr "|" "\n" | egrep '(^55=|^6=)'
但只拿到单独的行股票/价格是这样的:
but this only gets the stock/ price on separate lines like this:
IBM
AAPL
GE
138
130
11
有一个bash / UNIX单行将得到这个?
Is there a bash/unix one liner that will get this?
推荐答案
试试这个:
awk -F '[|=]' '{printf "%-6s %s\n", $8, $10}' file
输出:
IBM 138
APPL 130
GE 11
这篇关于使用grep解析股票,价格在列格式修复日志/ AWK / UNIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文