The format of the output is the same except that when using python, the output adds a new line between each string. Any idea why and how I can do this using sed?
sed 's:\x01: | :g'
01.06.2012 07:51:55.135 | 3732 | INFO | xxx | 8=FIX.4.2 | 9=157 | 35=V | 56=xxx | 49=xxx | 52=20120601-07:51:54 | 34=40 | 262=VMD1338537114945 | 263=1 | 264=0 | 265=1 |
01.06.2012 07:51:55.135 | 3732 | INFO | xxx | 8=FIX.4.2 | 9=157 | 35=V | 56=xxx | 49=xxx | 52=20120601-07:51:54 | 34=41 | 262=VLT1338537114945 | 263=1 | 264=1 | 265=1 |
for line in sys.stdin:
print line.replace("\01", " | ")
01.06.2012 07:51:55.135 | 3732 | INFO | xxx | 8=FIX.4.2 | 9=157 | 35=V | 56=xxx | 49=xxx | 52=20120601-07:51:54 | 34=40 | 262=VMD1338537114945 | 263=1 | 264=0 | 265=1 |
01.06.2012 07:51:55.135 | 3732 | INFO | xxx | 8=FIX.4.2 | 9=157 | 35=V | 56=xxx | 49=xxx | 52=20120601-07:51:54 | 34=41 | 262=VLT1338537114945 | 263=1 | 264=1 | 265=1 |
Add a second substitution that replaces the end of the line with a newline: s/$/\n/. Since you have two patterns now, you need to use -e:
sed -e 's:\x01: | :g' -e 's/$/\n/'
I'm not a sed guru, but you can add a newline at the end of every line in sed using the following:
sed -e 's/$/\n/g'
This works because $ matches the end of a line. Note that you can string multiple sed commands together with -e (as pointed out by Michael Mrozek -- see man sed for more info).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With