Changing the delimiter slash (/
) to pipe (|
) in the substitute command of sed
works like below
echo hello | sed \'s|he
I'm not sure what is intended by the command you mentioned:
echo hello | sed '/hello/i world'
However, I presume that you want to perform certain action on lines matching the pattern hello
. Lets say you wanted to change the lines matching the pattern hello
to world
. In order to accomplish that, you can say:
$ echo -e "something\nhello" | sed '\|hello|{s|.*|world|}'
something
world
In order to match lines using a regexp, the following forms can be used:
/regexp/
\%regexp%
where %
may be replaced by any other single character (note the preceding \
in the second case).
The manual provides more details on this.