sed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sed what chars need \escape?


From: Nora Platiel
Subject: Re: sed what chars need \escape?
Date: Sun, 22 Nov 2020 18:52:41 +0100

Hello,

1) Skip this step if you already have a sed regexp. If you have a string to be 
matched literally, you have to quote the following characters with a backslash:
$*.[\^
If you are using extended regular expressions you also need to quote these:
()+?{|}

2) The replacement part of the s-command is not a regexp, so 1) doesn't apply 
to it. In the replacement part you have to quote only \ and & which stand for 
portions of the match.

3) To use such strings inside a text matching address or an s-command you also 
have to quote the delimiter with a backslash. The delimiter is usually a slash 
(/) but can be something else.

4) Finally, if you want to embed your sed script into shell code you have to 
make sure it's treated literally by the shell.
One way is to put it between single quotes after replacing any single quote (') 
with \x27 (which is decoded by sed). The shell also allows for other quoting 
styles.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]