I have a JSON file which contains a list like this;
[{
"host": "cat",
"ip": "192.168.1.1",
"id": "cherry"
}, {
"host": "dog",
"ip": "192.168.1.1",
"id": "apple"
}, {
"host": "cat",
"ip": "192.168.1.2",
"id": "banana"
}]
I want to collect IPs and print id and host next to it but if IP is used multiple times then print multiple id and host next to instead of a new line. IP and host can be the same for multiple items but id is unique.
So the final output should look like this;
$ echo <something>
192.168.1.1 cat cherry dog apple
192.168.1.2 cat banana
How can I do this using bash and jq?