Link to home
Create AccountLog in
Avatar of MarkLoveExEx
MarkLoveExEx

asked on

sort this file using out-of-the-box Redhat Linux tools

Dear script writers,

Is there a way to sort the data in the attached file (using a script) where the oldest data is on the top, and the latest data is at the bottom? It would have to processed, keeping the "blocks" of data together and using the date info from the ".ER" lines.

A ".ER" line is the begining of a block of data. The spacing and format of the data can't be changed. Just need to blocks sorted. The date information is in the "ER" lines, as as follows:
.ER LAWV2    0224 E DC201602241659/DH19/HGIFF/DIH6
YYYYMMDDhhmm

Tools must be out of the box Redhad Linux. I know I have python, awk, shell script stuff. Whatever works the best...

Thanks for your help!
testfile.txt
ASKER CERTIFIED SOLUTION
Avatar of Maciej S
Maciej S
Flag of Poland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of MarkLoveExEx
MarkLoveExEx

ASKER

Excellent job. Thank you so much!  One thing I forgot to mention is that sometimes there are 5 lines of data, and sometimes there are 6 lines. But it looks like you took that into account, and the script works perfectly. Thanks again!