Shell Scripting -- sed

Hi,

In one of my scripts, I am using sed to do an expression replacement. The code in the script is as under

sed "s|MY_INP_Lab=""|MY_INP_Lab="${2}"|" file1, where $2=xyz_abc_mbk

The EXPECTED output is in file1, all the instances ofMY_INP_Lab="" shall be replaced by MY_INP_Lab="xyz_abc_mbk"

But the ACTUAL output is

MY_INP_Lab=xyz_abc_mbk""

Can someone please help in telling me why I am not getting the required output. And how can I get the expected output.

Thanks,
Vivek.

Try like this,

sed 's|MY_INP_Lab=""|MY_INP_Lab="'$2'"|' testfile1
1 Like

Hi Pravin,

I tried it and it works, Thanks.

Regards,
Vivek.