Joining records using sed or awk
Posted 07-01-2009 at 07:34 AM by JimRobinson
I have a very large file, 9 million records, and there are sections in the file where I need to join records. How can I get for example line number 100,000 and join to it lines 100,001-100,050 using sed or awk? The joins need to happen multiple times throughout the file. I can get the line number for the first and last line I need in my join but am having difficulty figuring out how to reformat the file with the lines joined and the file saved with the one end-resulting line.
Any suggestions? Thanks!!
Any suggestions? Thanks!!
Total Comments 2
Comments
-
Any suggestions would be greatly appreciated. We are archiving MQ messages and the messages recieved in XML format are causing the multiple records. To properly grep the file for researching, I need to have those records joined into one record. Thanks for any suggestions on this.
for instance...
1> <aaaaa>aabbccdd</aaaaa>
2> <bbbbb>aabbccdd
3> eeffgghhii
4> jjkkllmm</bbbbb>
I would want to join line 3 and 4 with 2 giving...
1> <aaaaa>aaaaabbbbbbcccccdddd</aaaaa>
2> <bbbbb>aabbccddeeffgghhiijjkkllmm</bbbbb>Posted 07-01-2009 at 08:48 AM by JimRobinson -
Start to play with these: http://sed.sourceforge.net/sedfaq4.html#s4.25 and http://sed.sourceforge.net/sedfaq4.html#s4.26 .
Posted 07-03-2009 at 07:34 AM by gabim