using ubuntu command line to replace text in huge file

Posted by user299331 on Ask Ubuntu See other posts from Ask Ubuntu or by user299331
Published on 2014-08-22T22:32:41Z Indexed on 2014/08/22 22:33 UTC
Read the original article Hit count: 171

Filed under:
|
|

hi i have a huge xml file that i must work with. right now the file is only 1 line that contains about 2 million characters which represent 30,000 records. there are no carriage returns or linefeeds whatsoever. what i need to do is make each record on its own line. new records begin with "" and end with "".

i've been looking around here and it seems the tools to use are: sed, tr or awk but i'm not sure which is most appropriate.

i've tried this to no avail:

tr '<ROW' '\012 <ROW' <source.xml |tee destination.xml

above seems to output some pretty weird stuff so i must be way off here. maybe its that "<" character that is the problem?

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about text