I'm trying to clean up the syntax of a pseudo-json file. The file is too large to open in a text editor (20 gb), so I have to do all of this via command line (running Arch linux). The one thing I cannot figure out how to do is replace new line characters in sed (GNU sed v. 4.8)
Specifically I have data of the form:
{
"id" : 1,
"value" : 2
}
{
"id" : 2,
"value" : 4
}
And I need to put a comma after the closed curly bracket (but not the last one). So I want the output to looks like:
{
"id" : 1,
"value" : 2
},
{
"id" : 2,
"value" : 4
}
Ideally I'd just do this in sed, but from reading about this, sed flattens the text first, so it's not clear how to replace newline characters.
Ideally I'd just run something like sed 's/}\n{/},\n{/g' test.json, but this doesn't work (nor does using \\n in place of \n).
I've also tried awk, but have run into similar issue of not being able to replace the combination of a hard return with brackets. And I can get tr to replace the hard returns, but not the combination of characters.
Any thoughts on how to solve this?