I have config.json file with the following content:
[{
"host0": "11.11.11.11",
"host1": "22.22.22.22",
"host2": "33.33.33.33",
"host3": "44.44.44.44",
"host4": "55.55.55.55",
"host5": "66.66.66.66"
}]
and I'm trying to create a .sh bash script that can be launched from command line and edit that config.json file to completely remove the whole host0 line along with its value. Then I need the remaining values to "move up" -- I mean rename host1 to host0, host2 to host1, host3 to host2, host4 to host3, etc etc, but their values should stay same. The end result should look like this:
[{
"host0": "22.22.22.22",
"host1": "33.33.33.33",
"host2": "44.44.44.44",
"host3": "55.55.55.55",
"host4": "66.66.66.66"
}]
How can I do it with bash script and jq, or any other method with bash script launchable from command line or/and cron? Hardcoding in .sh script like jq '.host0 = "22.22.22.22" config.json is not an option; I need the script to read config.json and copy values from host1 and paste it to host0 and so on.
{"hosts": ["11.11.11.11", "22.22.22.22", ...]}?hosts(sort) order ?