如何在单行中获取jq的输出? [英] How to get the output of jq in single line?

查看:73
本文介绍了如何在单行中获取jq的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将jq与aws cli一起使用来打印实例. 例如: 检索实例列表

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打印实例ID:

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

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..

推荐答案

尖括号字符真的在吗?否则,您可以简单地tr '\n' ','.

Are the angle bracket characters really there? Otherwise you can simply tr '\n' ','.

这篇关于如何在单行中获取jq的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆