Reputation: 824
Let's say I have a json file, I run cat testTab.json | jq '.action.service.spec.task| select(.container) | .container'
and it gives me
{
"image": "ubuntu:latest",
"args1": "tail",
"args2": "-f",
"args3": "/dev/null",
"mounts": {
"source": "/home/testVolume",
"target": "/opt"
},
"dns_config": null
}
How should I edit this command the get all args (args1, args2 and args3) values ("tail" "-f" "/dev/null")
Upvotes: 3
Views: 4718
Reputation: 92854
Complement your jq
pipeline with the following filter:
jq -r 'yourfilter | to_entries
| map(select(.key | test("^args[0-9]+")).value) | @tsv' testTab.json
The output:
tail -f /dev/null
Though, if you would have posted your initial testTab.json
contents - I would help to optimize your current filter.
Upvotes: 6