The below is my input file, say input.json
{
"server1": {
"name": "server1",
"property": "ENABLED"
},
"server2": {
"name": "server2",
"property": "ENABLED"
},
"server3": {
"name": "server3",
"property": "ENABLED"
},
"server4": {
"name": "server4",
"property": "ENABLED"
},
"server5": {
"name": "server5",
"property": "ENABLED"
},
"server6": {
"name": "server6",
"property": "ENABLED"
}
}
I am running the following jq query:
jq -r '.[] | select(.property == "ENABLED") |.name' input.json
I get the below output:
server1
server2
server3
server4
server5
server6
I want my output to be without any new line and as below, separated by space and no space after the last word (server6 in this case)
server1 server2 server3 server4 server5 server6
I don't want to do pipe after jq command and obtain the output with sed and tr commands. I want to achieve this with jq command only. Would appreciate the help. thanks.