Replace each } with a }\n in a huge (12GB) which consists of 1 line?

Viewed 136

I have a log file (from a customer). 18 Gigs. All contents of the file are in 1 line. I want to read the file in logstash. But I get problems because of Memory. The file is read line by line but unfortunately it is all on 1 line.

I tried split the file into lines so that logstash can process it (the file has a simple json format, no nested objects) i wanted to have each json in one line, splitting at } by replacing with }\n:

sed -i 's/}/}\n/g' NonPROD.log.backup

But sed is killed - I assume also because of memory. How can I resolve this? Can I let sed manipulate the file using other chunks of data than lines? I know by default sed reads line by line.

5 Answers
Related