Reputation: 11
Suppose I have this JSON file,
{
"tags": [
{
"name": "xxx1",
"image_id": "yyy1"
},
{
"name": "xxx2",
"image_id": "yyy2"
}
]
}
I want to parse just the values from key 'name' and save it to another text file example.txt.
My desired output in the text file would be
xxx1
xxx2
How do I do this?
Upvotes: 1
Views: 1607
Reputation: 99
Save your data in temp.json and use the below command.
cat temp.json | grep name | cut -d ":" -f 2 | cut -d "," -f 1 >> output.txt
Upvotes: 0