PDA

View Full Version : Insert line breaks into a very long line



LotsOfPhil
July 9th, 2008, 09:21 PM
Hello,

I have a text file that consists of one very long line (the file is 43 MB). It is a bunch of fixed-length records so I would like to put line breaks in every 494 characters.

I feel like this should be pretty easy to do with awk/sed, but can't figure it out. Can anyone give me some guidance?

Thanks.

Trumpen
July 9th, 2008, 10:03 PM
This should work


sed 's/.\{494\}/&\n/g' yourfile

LotsOfPhil
July 9th, 2008, 10:15 PM
Excellent. Thank you.