{"running": 1, "finished": 3, "node_name": "L-2.local", "pending": 0, "status": "ok"}
I'm trying to parse this response to check the value of "running" with a bash script. I know there's libraries to do this, but some reason the jq library wouldn't install, and I prefer not to install it, as I only need it for this one command. Normally I'd use Python instead.
I tried using this command from another answer, on the response
| grep -Po '"running":"\K[^,]*'
but it failed due to the "."
bash: {"running": 0, "finished": 0, "node_name": "L-2: command not found
Is there a way to get it to check the value of "running" with grep, and not have the error?
"in the pattern after:, but there is no quote in the string. Useecho '...string...' | grep -Po '"running":\s*\K[^,]+'. If you are sure there are digits only, use'"running":\s*\K\d+'sedto get the value, though it won't look pretty. See my answer.