鉴于以下json示例 - 如何在unix命令行的module2散列后用不同的字符串替换7个字符?
{
"module": "git+https://9gke37d40a7a9f84659e98f386d4ea2fda2a5d86:x-oauth-basic@github.com/org-name/repo.git#71e84fd",
"module2": "git+https://9gke37d40a7a9f9999e98f386d4ea2fda2a5d86:x-oauth-basic@github.com/org-name/repo.git#99h43ae",
"module3": "git+https://9gke37d40a7a9f33759e98f386d4ea2fda2a5d6:x-oauth-basic@github.com/org-name/repo.git#94i53bb"
}
答案 0 :(得分:0)
如果您有上述行,则可以
sed -i -e 's/(.*module2.*?#)(.......)(.*)/\1abcdefg\3/' json-file
其中abcdefg将是您的替换字符串。