2


I'd like to hear your suggestions about collecting from this string (which returned by a command) the value which is next to result (In this case 15) :

{
    "outcome" => "success",
    "result" => 15
}

Which utility/command to do suggest me ? Thanks Max

0

3 Answers 3

4
command | awk '$1=="\"result\"" {print $3}'
Sign up to request clarification or add additional context in comments.

Comments

4

GNU grep:

command | grep -oP '(?<="result" => )\d+'

Comments

2
$ awk '$1 == "\"result\"" { print $3 }' <<< "$STRING"

1 Comment

+1 for using a here-string but -1 for not quoting the variable

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.