jsonを使用してjsonファイルを解析しようとしています。JQを使用して名前 `end`のオブジェクトをフィルタリングできません
$cat ipres.txt
{
"start": {
"connected": [{
"socket": 5,
"local_host": "10.8.0.3",
"local_port": 36068,
"remote_host": "10.8.0.2",
"remote_port": 5201
}],
"version": "iperf 3.1.2",
"system_info": "Linux sid-Vostro-3700 3.13.0-77-generiC#121-Ubuntu SMP Wed Jan 20 10:50:42 UTC 2016 x86_64",
"timestamp": {
"time": "Fri, 22 Apr 2016 13:08:10 GMT",
"timesecs": 1461330490
},
"connecting_to": {
"host": "10.8.0.2",
"port": 5201
},
"cookie": "sid-Vostro-3700.1461330486.892347.18",
"test_start": {
"protocol": "UDP",
"num_streams": 1,
"blksize": 8192,
"omit": 0,
"duration": 2,
"bytes": 0,
"blocks": 0,
"reverse": 0
}
},
"intervals": [{
"streams": [{
"socket": 5,
"start": 0,
"end": 2.0002,
"seconds": 2.0002,
"bytes": 253952,
"bits_per_second": 1.01571e+06,
"packets": 31,
"omitted": false
}],
"sum": {
"start": 0,
"end": 2.0002,
"seconds": 2.0002,
"bytes": 253952,
"bits_per_second": 1.01571e+06,
"packets": 31,
"omitted": false
}
}],
"end": {
"streams": [{
"udp": {
"socket": 5,
"start": 0,
"end": 2.0002,
"seconds": 2.0002,
"bytes": 253952,
"bits_per_second": 1.01571e+06,
"jitter_ms": 828.078,
"lost_packets": 0,
"packets": 24,
"lost_percent": 0,
"out_of_order": 0
}
}],
"sum": {
"start": 0,
"end": 2.0002,
"seconds": 2.0002,
"bytes": 253952,
"bits_per_second": 1.01571e+06,
"jitter_ms": 828.078,
"lost_packets": 0,
"packets": 24,
"lost_percent": 0
},
"cpu_utilization_percent": {
"host_total": 7.7914,
"host_user": 1.09745,
"host_system": 6.69392,
"remote_total": 0,
"remote_user": 0,
"remote_system": 0
}
},
"test": 0
}
しかし、私が終了オブジェクトをフィルタリングしようとすると、私のコマンドは失敗します。私は例end1
のためにいくつかの他の名前にend
オブジェクトを変更した場合
$cat ipres.txt | jq .end
error: syntax error, unexpected end, expecting $end
.end
^^^
1 compile error
、私はできフィルタリングすることができます。何が問題なの?
と書くことができます。しかし、あなたが与えたことは '$ cat ipres.txt | jq .end'。それにもかかわらず、両方の出力は同じです(私の質問で述べたエラー)。 – Kumar
そして、あなたのソースファイルを再評価/見てみましょう: 'ipres.txt' - またはあなたが使っている' jq'のバージョン。自分で 'jq'をビルドしましたか? - うまく動作するファイルを貼り付けてコピーします。 – aphorise
はい私のせいです。私は古いバージョンのjqを使用していました。 JQ 1.5と一緒に試してみるとうまくいきます。以前のコメント(バージョンの不一致)を示す回答を更新できますか? – Kumar