I have a sed command that I use to insert a line into a shell script. The name of the script into which I insert varies in every env I'm trying to do this in. This works if I provide the values but when I need to repeat this across a large number of environments I need it to fetch these values from a json file. Any idea how I can achieve this?
Syntax -> sed -i '1 a if ! [ipaddress = <value> && OSTYPE = linux]; then exit(1); endif' qa-<envname>-vm1.sh
sed -i '1 a if ! [ipaddress = 0.0.0.0 && OSTYPE = linux]; then exit(1); endif' qa-QAF-vm1.sh
inserts
if ! [ipaddress = 0.0.0.0 && OSTYPE = linux]; then exit(1); endif
after the first line in the file qa-QAF-vm1.sh
.
Any ideas how I can fetch the ipaddress value
and envname
from a json file which lists these values?