繁体   English   中英

如何使用正则表达式或 grep 从此 json 中提取('uid')值?

[英]how to extract the ('uid') value using regex or grep from this json?

我有以下 API JSON 响应:

https://gist.github.com/mzaboss/944d30a1c29796cbe8dbb6aa95d7e20e

我想提取'uid': '6904989037985481733'的值。

例子:

6904989037985481733
6775449343043519493
6864191257082741765
6790990270277551110
6846402706555601926

ETC

我试过cat ids.txt | grep 'uid' cat ids.txt | grep 'uid' ,尝试失败。

如何制作准确的 grep?

谢谢,问候。

jq 是用于 json 的最佳工具,但鉴于链接中的 json 的格式似乎不正确,您可以使用以下内容获取 UID 条目:

grep -Eo "'uid': '[[:alnum:]]+'" file.json | cut -d "'" -f 4

Output 使用 grep 的 uid 键和条目,然后使用 cut 仅提取值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM