Escaping forward slashes in sed command [duplicate]

I suggest to replace

sed "s/regex/replace/" file

with

sed "s|regex|replace|" file

if your sed supports it. Then it is no longer necessary to escape the slashes.

The character directly after the s determines which character is the separator, which must appear three times in the s command.

Leave a Comment