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
Post a Comment