我有下面的JSON文件
[
{
"bw-parallel-streams": "1",
"destination": "198.124",
"event-types": [
{
"base-uri": "/esmond/perfsonar/archive/dfbd05cef48c4111b9da3cc1238f74ad/throughput-subintervals/base",
"event-type": "throughput-subintervals",
"summaries": [],
"time-updated": 1423675036
},
{
"base-uri": "/esmond/perfsonar/archive/dfbd05cef48c4111b9da3cc1238f74ad/failures/base",
"event-type": "failures",
"summaries": [],
"time-updated": null
},
{
"base-uri": "/esmond/perfsonar/archive/dfbd05cef48c4111b9da3cc1238f74ad/packet-retransmits/base",
"event-type": "packet-retransmits",
"summaries": [],
"time-updated": 1423675036
},
{
"base-uri": "/esmond/perfsonar/archive/dfbd05cef48c4111b9da3cc1238f74ad/throughput/base",
"event-type": "throughput",
"summaries": [
{
"summary-type": "average",
"summary-window": "86400",
"time-updated": 1423675036,
"uri": "/esmond/perfsonar/archive/dfbd05cef48c4111b9da3cc1238f74ad/throughput/averages/86400"
}
],
"time-updated": 1423675036
},
{
"base-uri": "/esmond/perfsonar/archive/dfbd05cef48c4111b9da3cc1238f74ad/packet-retransmits-subintervals/base",
"event-type": "packet-retransmits-subintervals",
"summaries": [],
"time-updated": 1423675036
}
],
"input-destination": "wash-pt1.es.net",
"input-source": "128.143",
"ip-transport-protocol": "tcp",
"measurement-agent": "128.143.231.161",
"metadata-count-total": 1,
"metadata-key": "dfbd05cef48c4111b9da3cc1238f74ad",
"source": "128.143.",
"subject-type": "point-to-point",
"time-duration": "20",
"time-interval": "21600",
"tool-name": "bwctl/iperf3",
"uri": "/esmond/perfsonar/archive/dfbd05cef48c4111b9da3cc1238f74ad/"
}
]
我想根据事件类型检索基uri。
我正在写一个bash脚本来实现这一点。我以前从未使用过JSON文件或编写过python代码,因此如果我的问题显得如此幼稚,我很抱歉。我可以在Bash中这样做吗?如果我使用python,它会更容易些?
谢谢你
我使用的是jshon,我相信它可以在ubuntu的存储库中找到:
我还没有测试过,但您需要做的是:
^{pr2}$可以打印1423675036
更多信息请参见此处:http://kmkeen.com/jshon/
相关问题 更多 >
编程相关推荐