How to get the output of jq in single line?

Viewed 1869

I have used jq with aws cli to print the instances . Eg: Retrieve instances list

aws ec2 describe-instances --filters "Name=tag:bld_env,Values=test" --output json > all-inst.json

Jq to print instances id :

jq -r '.Reservations[].Instances[].InstanceId' all-inst.json

Output of Jq:

 i-09e0d805cc 
 i-091a61038 
 i-07d3022
 i-0428ac7c4c
 i-970dc5c4d99 
 i-014c4ea
 i-0ac924df
 i-031f6 and so on..

I want to print them in a line like this :

i-09e0d805cc,i-091a61038,i-07d3022,i-0428ac7c4c,i-970dc5c4d99,i-014c4ea,i-0ac924df,i-031f6 and so on..
2 Answers
Related