小编use*_*747的帖子

grep命令从json中查找key的值

请解释如何使用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.

如果是,请解释.

linux

4
推荐指数
1
解决办法
2万
查看次数

如何在shell脚本中的文件中每行的末尾添加一个字符

我需要一个脚本,在每行的末尾添加一个特定的字符.我正在使用命令
sed的/ $/foo /'r.txt

它将foo添加到文件r.txt中每行的末尾并显示在我的终端中.如果我想在每行结束后附加此新记录来保存此现有文件,我该怎么办?

linux bash shell

0
推荐指数
1
解决办法
2万
查看次数

标签 统计

linux ×2

bash ×1

shell ×1