Eu não sei se esse é o título certo para a minha pergunta. Por favor me perdoe com isso.
O código que tentei não está recebendo a saída exata que desejo.
Este é o meu código que eu tentei:
curl -s --request GET \
http://10.10.5.242/api/v1/incidents \
-H "Content-Type: application/json;" \
-H "X-Cachet-Token: ROvbssneyYwR8fwNgOWj" \
| json_pp | grep -e id -e component_id
E isso produzirá isso
"component_id" : "4",
"id" : 1,
"id" : 2,
"component_id" : "4",
"id" : 3,
"component_id" : "4",
"component_id" : "4",
"id" : 4
"component_id" : "3",
"id" : 5,
"component_id" : "2",
"id" : 6,
Este é o conteúdo da API que estou usando o link
{
"meta": {
"pagination": {
"total": 6,
"count": 6,
"per_page": 20,
"current_page": 1,
"total_pages": 1,
"links": {
"next_page": null,
"previous_page": null
}
}
},
"data": [
{
"id": 1,
"component_id": "4",
"name": "Service Unavailable",
"status": "4",
"visible": 1,
"message": "Server is not responding",
"scheduled_at": "2018-02-26 10:05:03",
"created_at": "2018-02-23 14:56:16",
"updated_at": "2018-02-26 08:37:11",
"deleted_at": null,
"human_status": "Fixed"
},
{
"id": 2,
"component_id": "4",
"name": "Service Unavailable",
"status": "4",
"visible": 1,
"message": "Server is not responding",
"scheduled_at": "2018-02-26 10:05:03",
"created_at": "2018-02-23 15:39:52",
"updated_at": "2018-02-26 08:37:11",
"deleted_at": null,
"human_status": "Fixed"
},
{
"id": 3,
"component_id": "4",
"name": "Service Unavailable",
"status": "4",
"visible": 1,
"message": "Server is not responding",
"scheduled_at": "2018-02-26 10:05:03",
"created_at": "2018-02-26 08:15:43",
"updated_at": "2018-02-26 08:37:12",
"deleted_at": null,
"human_status": "Fixed"
},
{
"id": 4,
"component_id": "4",
"name": "Service Unavailable",
"status": "4",
"visible": 1,
"message": "Server is not responding",
"scheduled_at": "2018-02-26 10:05:03",
"created_at": "2018-02-26 08:19:12",
"updated_at": "2018-02-26 08:37:12",
"deleted_at": null,
"human_status": "Fixed"
},
{
"id": 5,
"component_id": "3",
"name": "Service Unavailable",
"status": "2",
"visible": 1,
"message": "Server is not responding",
"scheduled_at": "2018-02-26 10:05:03",
"created_at": "2018-02-26 10:01:32",
"updated_at": "2018-02-26 10:01:32",
"deleted_at": null,
"human_status": "Identified"
},
{
"id": 6,
"component_id": "2",
"name": "Service Unavailable",
"status": "2",
"visible": 1,
"message": "Server is not responding",
"scheduled_at": "2018-02-26 10:05:03",
"created_at": "2018-02-26 10:03:38",
"updated_at": "2018-02-26 10:03:38",
"deleted_at": null,
"human_status": "Identified"
}
]
}
A saída que eu quero é pegar todo o id de "component_id": "4" , e irá mostrar isso
"id" : 1,
"id" : 2,
"id" : 3,
"id" : 4,
O que eu queria é grep o component_id e obterá todos os valores do id do ID do componente.
Porque meu plano é trazer esses valores no meu loop.