2

I'm currently trying to parse my FIX messages to get 2 columns showing currency (tag55) and price (tag133) but having difficulty using 'awk' as it appears the desired part of the message isn't split into columns (in bold for your reference). Any thoughts on how to accomplish this?

FIX log example:
03:55:16.128 incoming           20180528-07:55:16.015           8587130         11891           8587030         S                  **8=FIX.4.29=013535=S49=IUAT2Feed56=FixServer50=IUAT2Feed_Offers34=858713052=20180528-07:55:16.015117=055=NOK/SEK7225=7133=1.0735135=2100000010=159**
03:55:16.128 incoming           20180528-07:55:16.015           8587131         11891           8587030         S                  **8=FIX.4.29=013435=S49=IUAT2Feed56=FixServer50=IUAT2Feed_Offers34=858713152=20180528-07:55:16.015117=055=USD/CNH7225=2133=6.3872135=300000010=110**

Desired output:

NOK/SEK 1.0735
USD/CNH 6.3872
  • awk -F'=' '{gsub(/7225/,""); print $11, $13}' file – jasonwryan May 28 '18 at 8:14
0
  perl -F= -pale '$_ = sprintf "%.7s %.4f", @F[-5,-3]'   fix.log

¶ how it works :

 °  split each line as it comes on equal to sign. Store the split values in the array @F

 °  counting from the end of the array @F, the last but 4th  and last but 2nd fields are what we need.

 °  we require the 7 chars and accuracy upto 4 digits.

 °  stuff these in $_ and -p option auto prints it. 
0

Following awk may help you here.

awk -F"=" '{sub(/[0-9]+/,"",$(NF-4));print $(NF-4),$(NF-2)+0}' OFMT="%.05g"  Input_file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.