AWK experts - how would I code around this in awk...

Steve Flynn anothermindbomb at gmail.com
Thu Feb 18 18:02:20 UTC 2010


I have a text file with lines of differing length.

I want  to parse the entire file and make each line (for example) 20 bytes long.

If a record is too short as in the following example: (rec1,2 and 3
are just so I can refer to them easily - the example file should be
just the numeric portion).

rec1 123456789012345
rec2 67890
rec3 12345678901234567890

... then I need to append rec2 to rec1.

Obviously after appending rec2 to rec1, the next line to be read
should be rec3. After completion, the entire file would consist of two
records in this example case, both 20 bytes long.



I should point out that the complete file may well be in the hundreds
of millions of records so holding the entire thing in memory is
probably not a good idea.

Any idea on how I would go about this in awk?

If you believe awk to not be a good candidate for this, I'm open to
suggestions on alternatives.


(as a side note, this is for some data which I need to parse which has
embedded CF/LF's in it, thus splitting what should be one record into
perhaps multiples rows... I need a quick (and easy) way of stitching
it back together.


-- 
Steve
When one person suffers from a delusion it is insanity. When many
people suffer from a delusion it is called religion.

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0




More information about the ubuntu-users mailing list