This task is similar to this one but in my case I would like to go other way around. So say we have input:
[
{
"name": "John",
"email": "[email protected]"
},
{
"name": "Brad",
"email": "[email protected]"
}
]
and desired output is:
{
"name": "John",
"email": "[email protected]"
}
{
"name": "Brad",
"email": "[email protected]"
}
I tried to write a bash function which will do it in loop:
#!/bin/bash
json=`cat $1`
length=`echo $json | jq '. | length'`
for (( i=0; i<$length ; i++ ))
do
echo $json | jq ".[$i]"
done
but it is obviously extremly slow...
Is there any way how to use jq better for this?