Question Locked

using SED to replace string with / /

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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 \. ???

2 replies

by cls8

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.

This discussion is closed to new replies.