I am trying to split a json file into various json files. The input (r1.json) looks like this:
{
"results" : [
{
content 1
}
,
{
content 2
}
,
{
content n
}
]
}
I want the output to have n files: 1.json, 2.json, n.json. Accordingly, containing {content 1}, {content 2} and {content n}.
I tried:
for i in {0..24}; do cat r1.json | jq '.results[$i]' >> $i.json; done
But I have the following error: error: I am not defined
source
share