1

My curl output is

{
    "router": {
        "node_id": "ip-1-2-3-4",
        "state": "HEALTHY",
        "message": "OK"
    },

I want to get the output as

state:HEALTHY

How can i get that i'm trying

curl -sk https://localhost/router/api/v1/system/heealth | grep -Eo router.*\n.*\n.*\"state\": \"HEALTHY\"

1 Answer 1

2

use jq to parse JSON, way easier than grep:

curl -sk https://localhost/router/api/v1/system/heealth|jq -r .router.state
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.