Aravindhan K Aravindhan K - 1 year ago 111
Linux Question

SED Replace with Slashes and Words

I am trying to replace a particular command. CDBFILELOCATION to +DATAC1/vbmtmdppg/ but it doesn't seem to be working. I saw some reference but all they have give is a blank slash example which is hard to understand. Please find the command i am using right now.

sed -i 's/CDBFILELOCATION/+DATAC1/vbmtmdppg/g' /u01/app/oracle/admin/vbmtmdpp/cr_db/mtmp_plug_pdb.sql

I get the error below
sed: -e expression #1, char 27: unknown option to `s'

Answer Source

You must escape the / in the replacement string:

sed -i 's/CDBFILELOCATION/+DATAC1\/vbmtmdppg/g' /u01/app/oracle/admin/vbmtmdpp/cr_db/mtmp_plug_pdb.sql

Alternatively, you can use a different delimiter in place of /:

sed -i 's|CDBFILELOCATION|+DATAC1/vbmtmdppg|g' /u01/app/oracle/admin/vbmtmdpp/cr_db/mtmp_plug_pdb.sql
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download