# How to create a report using awk - gensub function on FIX gateway log

**URL:** <https://forum.fixtrading.org/t/how-to-create-a-report-using-awk-gensub-function-on-fix-gateway-log/14188>\
**Category:** General Q&A\
**Tags:** fix-technology\
**Created:** [September 10, 2018, 2:52pm UTC](https://forum.fixtrading.org/t/how-to-create-a-report-using-awk-gensub-function-on-fix-gateway-log/14188 "2018-09-10T14:52:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavanfix](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.fixtrading.org/pavanfix/32/239_2.png) [@pavanfix](https://forum.fixtrading.org/u/pavanfix)\
**Post date:** [September 10, 2018, 2:52pm UTC](https://forum.fixtrading.org/t/how-to-create-a-report-using-awk-gensub-function-on-fix-gateway-log/14188/1 "2018-09-10T14:52:16Z")

</div>

below is the an example fix messages, considering we have only 2 reject messages on this specific gateway.  
and also the AWK gensub command to get the time, order ID and Reject message (tag 58)

[PAVANFIX@HOST logs]$ zgrep 150=8 OUTBOUND\_BANK\_FIRMA\_FIRMB.log.2018-09-04.gz | less  
10:02:01.420 INFO [JsonThread] - FIX.4.2:FIRMA-\>PKFIX: 8=FIX.4.2^A9=295^A35=8^A34=2133^A49=FIRMA^A52=20180904-14:02:01.420^A56=FIRMB^A57=JOHN^A128=BANK^A1=332^A6=0^A11=1809040000000ABCDEF^A14=0^A17=ABCD809040004379EF^A20=0^A29=1  
^A37=QWER80904000059977^A38=210^A39=8^A40=1^A47=A^A54=2^A55=PKK^A58=StopPrice only supported on STOP and STOP\_LIMIT orders^A59=0^A75=20180904^A99=0^A150=8^A151=0^A10=252^A  
13:15:30.672 INFO [JsonThread] - FIX.4.2:FIRMA-\>PKFIX: 8=FIX.4.2^A9=279^A35=8^A34=225243^A49=FIRMA^A52=20180904-17:15:30.672^A56=FIRMB^A57=JOHN^A128=BANK^A1=334^A6=0^A11=1809040000000GHIJKL^A14=0^A17=712180904000959849^A20=0^A29=1  
^A37=QEER80904000059977^A38=1400^A39=8^A40=1^A47=A^A54=1^A55=PKK^A58=End time should be after current time^A59=0^A65=A^A75=20180904^A150=8^A151=0^A10=108^A

[PAVANFIX@HOST logs]$ zgrep -w 150=8 OUTBOUND\_BANK\_FIRMA\_FIRMB.log.2018-09-04.gz | tr ‘\001’ ‘|’ | sed ‘s/ INFO /,/g’ | awk 'BEGIN {print “\n|----Time—| |----Order\_ID-----| |----------------------------------Reason-------------------------------------|n”} {x=gensub(/(._),.11=(.)|14.58=(.)|59._/ , " \1 \2 \3" , “g”) ; print x;} ’ ; date

|----Time—| |----Order\_ID-----| |----------------------------------Reason-------------------------------------|n  
10:02:01.420 1809040000000ABCDEF StopPrice only supported on STOP and STOP\_LIMIT orders  
13:15:30.672 1809040000000GHIJKL End time should be after current time

---

<div class="post-metadata">

**Author:** ![jorgthonnes](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.fixtrading.org/jorgthonnes/32/196_2.png) [@jorgthonnes](https://forum.fixtrading.org/u/jorgthonnes)\
**Post date:** [September 11, 2018, 6:02am UTC](https://forum.fixtrading.org/t/how-to-create-a-report-using-awk-gensub-function-on-fix-gateway-log/14188/2 "2018-09-11T06:02:00Z")

</div>

Nice, but I wonder how the sub-regexp `(.)` matches several letters…

---

<div class="post-metadata">

**Author:** ![pavanfix](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.fixtrading.org/pavanfix/32/239_2.png) [@pavanfix](https://forum.fixtrading.org/u/pavanfix)\
**Post date:** [September 12, 2018, 6:11pm UTC](https://forum.fixtrading.org/t/how-to-create-a-report-using-awk-gensub-function-on-fix-gateway-log/14188/3 "2018-09-12T18:11:14Z")

</div>

ahh, good question. it is actually .\* which I initially typed but the final editor removed \* from it

 ![FIX_error](https://canada1.discourse-cdn.com/flex010/uploads/fixtrading2/original/1X/680283423d8d578baf5ba54aa0b660c3984981cd.PNG)

---

<div class="post-metadata">

**Author:** ![jorgthonnes](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.fixtrading.org/jorgthonnes/32/196_2.png) [@jorgthonnes](https://forum.fixtrading.org/u/jorgthonnes)\
**Post date:** [September 13, 2018, 6:11am UTC](https://forum.fixtrading.org/t/how-to-create-a-report-using-awk-gensub-function-on-fix-gateway-log/14188/4 "2018-09-13T06:11:55Z")

</div>

Yes, editor markup may be tricky…😀

---

<div class="post-metadata">

**Author:** ![hanno.klein](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.fixtrading.org/hanno.klein/32/38_2.png) [@hanno.klein](https://forum.fixtrading.org/u/hanno.klein)\
**Post date:** [September 13, 2018, 8:25am UTC](https://forum.fixtrading.org/t/how-to-create-a-report-using-awk-gensub-function-on-fix-gateway-log/14188/5 "2018-09-13T08:25:27Z")

</div>

You can escape “\*” with a single backslash (“\”) to avoid interpretation as markdown command for italic emphasis.

> [PAVANFIX@HOST logs]$ zgrep -w 150=8 OUTBOUND\_BANK\_FIRMA\_FIRMB.log.2018-09-04.gz | tr ‘\001’ ‘|’ | sed ‘s/ INFO /,/g’ | awk 'BEGIN {print “\n|----Time—| |----Order\_ID-----| |----------------------------------Reason-------------------------------------|n”} {x=gensub(/(.\*),.11=(.\*)|14.58=(.\*)|59./ , " \1 \2 \3" , “g”) ; print x;} ’ ; date
