【发布时间】:2019-03-08 19:29:51
【问题描述】:
我正在尝试替换 json 中运行时的值,即
旧
{
"containerDefinitions": [{
"name": "containername",
"image": "myimage",
"memory": 512,
"cpu": 1,
"essential": true,
"portMappings": [{
"hostPort": 80,
"containerPort": 80,
"protocol": "tcp"
}]
}],
"volumes": [],
"family": "containername"
}
应该是新的
{
"containerDefinitions": [{
"name": "containername",
"image": "new image",
"memory": 512,
"cpu": 1,
"essential": true,
"portMappings": [{
"hostPort": 80,
"containerPort": 80,
"protocol": "tcp"
}]
}],
"volumes": [],
"family": "containername"
}
- 旧值:-“image”:“myimage”
- 新值:-“图像”:“新图像”
我想用 bash 做。有什么最好的办法吗?可以通过jq吗?
【问题讨论】:
-
是特殊的还是普通的换词?
-
值可以是任何东西。所以它应该检查关键字“image”并替换值
标签: bash