加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – grep命令从json中查找key的值

发布时间:2020-12-14 00:34:57 所属栏目:Linux 来源:网络整理
导读:请解释如何使用grep命令从以下json中提取一些指定的文本 – {"result":"Customer information saved successfully with Customer id :59 and version :1","status":{"responseCode":200,"result":null,"responseMessage":"Success","responseType":"info"}}
请解释如何使用grep命令从以下json中提取一些指定的文本 –

{"result":"Customer information saved successfully with Customer id :59 and version :1","status":{"responseCode":200,"result":null,"responseMessage":"Success","responseType":"info"}}

经过一些谷歌搜索后,通过使用带正则表达式的grep看起来是可能的.但它没有用.你能指出错误吗?

cat response.txt | grep -Po '(?<="Customer id ":)[0-9]+'

假设:response.txt包含上面的json.

如果是,请解释.

解决方法

你错过了K:

cat response.txt | grep -Po 'Customer id :K[0-9]+'
59

截图,它的工作原理:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读