SED command to replace strings with in file -


i trying use sed replace strings special characters in text file. sed command becoming complicated. if please me exact command.

code -  sed -i 's;ps1='${hostname} [$oracle_sid] $pwd> ';ps1="${col_yellow}'customer test:${hostname}:[$oracle_sid]:$pwd> '${col_end}";g' 

i tried escape special characters below not working.

sed -i 's;ps1=\'\${hostname} [\$oracle_sid] \$pwd> \';ps1="\${col_yellow}\'customer test:\${hostname}:[\$oracle_sid]:\$pwd> \'\${col_end}";g' .bash_profile_backup 

this might work (gnu sed):

sed -i 's|ps1='\''${hostname} \[$oracle_sid\] $pwd> '\''|ps1="${col_yellow}'\''customer test:${hostname}:[$oracle_sid]:$pwd> '\''${col_end}"|g' file 

n.b. ' need quoted in both pattern , replacement whereas [] needs escaped in pattern only.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -