using SED to replace string with / /

By sach2_in ·
how do i replace "hi" with "how / are / you " in a file using sed .

the problem is sed gives error when replacing due to presence of " / " in the value to be replaced .

one way on doing it is to use escape "\" before occurance of / .

Is there any other method without using escape \. ???

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

too easy

by cls In reply to using SED to replace stri ...

I don't have access to a commercial unix here, so I can't check the AT&T or BSD implementations, but this works in GNU, which is probably what you've got.

sed -e 's,hi,how / are / you,'

You can use any character to delimit the regex and the replacement. / is just traditional. Perl's s/// and m// operators work that way too.

Related Discussions

Related Forums