How to extract two fields from a JSON file using jq?
When I run 'jq '.node' out.json I get the word 'null' in output
Here is what I have in a file named out.json
head out.json
{ "items": [ {"node":"aaaa-cn001.me.com","status":"success","result":{"stdout":"3.10.0-957.12.1.el7.x86_64\n","stderr":"","exit_code":0}} , {"node":"aaaa-cn002.me.com","status":"success","result":{"stdout":"3.10.0-957.10.1.el7.x86_64\n","stderr":"","exit_code":0}} , {"node":"aaaa-cn003.me.com","status":"success","result":{"stdout":"3.10.0-957.10.1.el7.x86_64\n","stderr":"","exit_code":0}} , {"node":"aaaa-cn004.me.com","status":"success","result":{"stdout":"3.10.0-957.12.1.el7.x86_64\n","stderr":"","exit_code":0}}
I would like the output to be this way:
aaaa-cn001.me.com 3.10.0-957.12.1.el7.x86_64
aaaa-cn002.me.com 3.10.0-957.10.1.el7.x86_64
aaaa-cn003.me.com 3.10.0-957.10.1.el7.x86_64
aaaa-cn004.me.com 3.10.0-957.12.1.el7.x86_64
]}at the end). People answering questions are more likely to do so if they don't have to massage your sample data.