My Aim is to replace the value of some variables by identifying the variable name and by using sed.
However, i'm not getting the desired output, the value instead of getting replaced is actually getting appended.
Input file content:
export TENANT_NAME=xxxx
export WONDER_VALUE=xxx_xxx_xxxx_xxxx
export LOAD_BALANCERS=xxxx_xx
Bash Script:
#!/bin/bash
sed "s/${1}=*/${1}=${2}/" input.env >> input.env
Command:
./replaceValue.sh WONDER_VALUE BOB_ROB_ALICE
Result which I get:
export TENANT_NAME=xxxx
export WONDER_VALUE=BOB_ROB_ALICExxx_xxx_xxxx_xxxx
export LOAD_BALANCERS=xxxx_xx
Result I expect:
export TENANT_NAME=xxxx
export WONDER_VALUE=BOB_ROB_ALICE
export LOAD_BALANCERS=xxxx_xx