We have the following example file ( very long file , this is short example )
"request_status" : "FAILED"
{
"href" : "http://localhost:8080/api/v1/clusters/sys41/requests/333",
"Requests" : {
"cluster_name" : "sys41",
"id" : 333,
"request_status" : "COMPLETED"
}
},
{
"href" : "http://localhost:8080/api/v1/clusters/sys41/requests/334",
"Requests" : {
"cluster_name" : "sys41",
"id" : 334,
"request_status" : "FAILED"
}
},
{
"href" : "http://localhost:8080/api/v1/clusters/sys41/requests/335",
"Requests" : {
"cluster_name" : "sys41",
"id" : 335,
"request_status" : "FAILED"
}
},
{
"href" : "http://localhost:8080/api/v1/clusters/sys41/requests/336",
"Requests" : {
"cluster_name" : "sys41",
"id" : 336,
"request_status" : "COMPLETED"
}
}
how to print the line after the line that matches "id" : $num
e.g. for
num=335
how to get the line after
"id" : $num
Expected output
"request_status" : "FAILED"
jqwhich is the tool specifically built for querying JSON objects, but I am not fluent enough to impart unto you the correct incantation.jqsolution when the JSON is so severely mangled at the top.