Wednesday, December 29, 2010

Best way of Escaping / in SED

If you are using SED and have the search or replace string as / then the best way to do that is use some other character as a SED delimiter instead of /. This way you will not have to escape /. It will be treated as any other character in the string.

If you are using SED as:
sed "s/old/new/"
and the old and new strings have a / somewhere in between them then use SED as below:
sed "s=old=new="
This way / becomes as another character and you don't need to escape it.

No comments:

Post a Comment