bash - 我正在编写一个 bash 脚本,但我被困在使用“jq”命令进行管道传输的地方
问题描述
我的输入 JSON:
{
"PendingMaintenanceActions": [
{
"ResourceIdentifier": "arn:aws:rds:xxxxxx1230000345",
"PendingMaintenanceActionDetails": [
{
"Action": "hardware-maintenance",
"AutoAppliedAfterDate": "2020-12-17T08:00:00Z",
"ForcedApplyDate": "2020-12-18T13:00:00Z",
"CurrentApplyDate": "2020-12-17T08:00:00Z",
"Description": "Maintenance on the underlying hardware"
}
]
}
]
}
所需输出:
arn:aws:rds:xxxxxx1230000345,hardware-maintenance,2020-12-17T08:00:00Z,Maintenance on the underlying hardware
我尝试了很多,但没有运气。有人可以帮我获得所需的输出。
谢谢你。
解决方案
aws rds ... | jq '.PendingMaintenanceActions[].ResourceIdentifier + "," + .PendingMaintenanceActions[].PendingMaintenanceActionDetails[].Action + "," + .PendingMaintenanceActions[].PendingMaintenanceActionDetails[].CurrentApplyDate + "," + .PendingMaintenanceActions[].PendingMaintenanceActionDetails[].Description'
不确定需要哪个日期,但 CurrentApplyDate 可以根据需要更改
推荐阅读
- c# - 子弹轨迹中的死区 - unity 2d
- ios - UITableViewCell 公共功能未执行
- c++ - 是 std::promise
无锁? - xml - 用于解压缩 xlsx 并从工作表 xml 文件中读取内容的 Powershell 脚本
- javascript - chrome扩展打开网站弹出窗口后停止工作如何解决?
- java - Firebase - 在用户之间发送消息
- ionic-framework - 离子显示来自 API 的音频流
- r - 获取给定产品总和内的所有可能组合
- c - 如何在c中正确实现strcpy?
- apache-spark - Spark GraphFrames High Shuffle 读/写