请解释如何使用grep命令从以下json中提取一些指定的文本 -
{"result":"Customer information saved successfully with Customer id :59 and version :1","status":{"responseCode":200,"result":null,"responseMessage":"Success","responseType":"info"}}
Run Code Online (Sandbox Code Playgroud)
经过一些谷歌搜索后,通过使用带正则表达式的grep看起来是可能的.但它没有用.你能指出错误吗?
cat response.txt | grep -Po '(?<="Customer id ":)[0-9]+'
Run Code Online (Sandbox Code Playgroud)
假设:response.txt包含上面的json.
如果是,请解释.
你错过了K:
cat response.txt | grep -Po 'Customer id :\K[0-9]+'
59
Run Code Online (Sandbox Code Playgroud)
截图,它的工作原理:
