LinuxSay - A Discussion Forum for Linux Enthusiasts

How to replace json parameter dynamically


#1

I need to change the “version” value at run time. How it can be done via shell script? as per below json, I need to replace “20181018” with “20181234”. No more change OR extra space should come.

{
“app”: “Deploy”,
“env”: “UAT”,
“versions”: [
{
“version”: “20181018”,
}
]
}


#2

In above query, that new parameter would be supplied via an argument which would be passed along with the shell.
For an instance, If change.sh is the script, Then I would be executing it as

./change.sh 20181234

So, change.sh should change the value “20181018” with $1 in json file.
Hope, it clarifies the requirement