sed-devel
[Top][All Lists]
Advanced

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

Re: to \escape or not to escape - that is the question ( & AMPERSAND )


From: Nora Platiel
Subject: Re: to \escape or not to escape - that is the question ( & AMPERSAND )
Date: Mon, 23 Nov 2020 18:36:00 +0100

On Mon, 23 Nov 2020 10:35:11 +0100, admin4 wrote:
> my tool will escape \" and \& in the future

There's actually no reason to escape ", but if you do, it still works because 
\" has no special meaning in sed.
Overquoting is kind of a dark corner though, since the doc only guarantees that 
\C matches C if C is one of $*.[\^

> (it is strange... when not escaping & it will not replace but ADD the
> string 'quot' behind the " that is supposed to be replaced)

See the doc for the s-command. Unquoted & characters in the replacement 
reference the whole matched portion of the pattern space.

$ echo a | sed 's/\w/&&&/'
aaa




reply via email to

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