Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想听听您关于从该字符串(由命令返回)收集结果旁边的值(在本例中为 15)的建议:
{ "outcome" => "success", "result" => 15 }
哪个实用程序/命令建议我?谢谢马克斯
command | awk '$1=="\"result\"" {print $3}'
GNU grep:
GNU grep
command | grep -oP '(?<="result" => )\d+'
$ awk '$1 == "\"result\"" { print $3 }' <<< "$STRING"