So I have this file, horribly formatted:
cat file1
220914230708E2022091416195068167642220000039TE OKaaaaaaaaaa 0000000017316354827094010600 aaaaaaaaaa 001 2022091416123467540807620001105TE OKbbbbbbbbbb 0000000292934354487119918680 bbbbbbbbbb 001 2022091416483567002141420000731TE OKDFDFJFSDFHS 0000000199137867325032383540 2022091419204463543285020000412TE OKcccccccccc 0000000111113867351043007780 cccccccccc 1EP 2022091419372363503707220000233TE OKddddddddddd 0000000067822353828105648630 ddddddddddd 001
And I would like to make it more readable.
I noticed the first field always ends up with "TE", so I tried this (and it almost worked).
awk ' BEGIN { RS = "TE" } { if ( $0 ~ "OK" ) print "TE" $0 }' file1
TE OKaaaaaaaaaa 0000000017316354827094010600 aaaaaaaaaa 001 2022091416123467540807620001105
TE OKbbbbbbbbbb 0000000292934354487119918680 bbbbbbbbbb 001 2022091416483567002141420000731
TE OKDFDFJFSDFHS 0000000199137867325032383540 2022091419204463543285020000412
TE OKcccccccccc 0000000111113867351043007780 cccccccccc 1EP 2022091419372363503707220000233
TE OKddddddddddd 0000000067822353828105648630 ddddddddddd 001
This is what I'm trying to accomplish:
2022091416123467540807620001105TE OKbbbbbbbbbb 0000000292934354487119918680 bbbbbbbbbb 001
2022091416483567002141420000731TE OKDFDFJFSDFHS 0000000199137867325032383540
2022091419204463543285020000412TE OKcccccccccc 0000000111113867351043007780 cccccccccc 1EP
2022091419372363503707220000233TE OKddddddddddd 0000000067822353828105648630 ddddddddddd 001
I know the problem is that I'm not correctly identifying the pattern, but I'm not sure what to do next.
Any help would be greatly appreciated.