【发布时间】:2019-05-23 11:22:17
【问题描述】:
My json
{
"license": " See license.md",
"dependencies": {
"@gx/core": "0.279.0-b1-abc-1234-0716.4567",
"@gx/api": "0.279.0-b1-abc-1234-0716.4567",
"@gx/name": "0.279.0-b1-abc-1234-0716.4567"
}
}
我想在所有地方将“0.279.0-b1-abc-1234-0716.4567”替换为“0.279.0-b1-abc-1234-0716.9856”。
jq '.dependencies[].["@gx/core"] |= (if . == "0.279.0-b1-abc-1234-0716.4567" then "0.279.0-b1-abc-1234-0716.9856" else . end)' info.json
jq: error: syntax error, unexpected '[', expecting FORMAT or QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:
.dependencies[].["@gx/core"] |= (if . == "0.279.0-b1-abc-1234-0716.4567" then "0.279.0-b1-abc-1234-0716.9856" else . end)
jq: 1 compile error
I am looking for something like this
jq '.dependencies[].["@gx/[a-z]*"] |= (if . == "^(\d+\.){2}[0-9]+(-[a-zA-Z0-9]*){4}\.[0-9]*$" then "0.279.0-b1-abc-1234-0716.9856" else . end)' info.json
【问题讨论】: