I would like to udpate a file config.yaml file by inserting some configuration parameters via bash.
The file to be updated looks like:
{
"log": [
{
"format": "plain",
"level": "info",
"output": "stderr"
}
],
"p2p": {
"topics_of_interest": {
"blocks": "normal",
"messages": "low"
},
"trusted_peers": [
{
"address": "/ip4/13.230.137.72/tcp/3000",
"id": "fe3332044877b2034c8632a08f08ee47f3fbea6c64165b3b"
}
]
},
"rest": {
"listen": "127.0.0.1:3100"
}
}
And it needs to look like:
{
"log": [
{
"format": "plain",
"level": "info",
"output": "stderr"
}
],
"storage": "./storage",
"p2p": {
"listen_address":"/ip4/0.0.0.0/tcp/3000",
"public_address":"/ip4/0.0.0.0/tcp/3000",
"topics_of_interest": {
"blocks": "normal",
"messages": "low"
},
"trusted_peers": [
{
"address": "/ip4/13.230.137.72/tcp/3000",
"id": "fe3332044877b2034c8632a08f08ee47f3fbea6c64165b3b"
}
]
},
"rest": {
"listen": "127.0.0.1:3100"
}
}
so adding
- on the first level
"storage": "./storage",
- and on the second level in the
p2p
section"listen_address":"/ip4/0.0.0.0/tcp/3000",
and"public_address":"/ip4/0.0.0.0/tcp/3000",
How do I do this with sed
?
For YAML to JSON editor checkout---YAML to JSON editor