Re: How to use a remembered pattern in a GNU sed embedded shell command?

"Tim Chase [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 2015-02-11 01:47, [email protected] [sed-users] wrote:
> sed -i 's@<span class="math">$\(.*\)$</span>@echo \1 \@ge' $1
> 
>  Above variant fails with the following error:
>  sed: -e expression #1, char 49: unterminated `s' command
>  By the way, character 49 is the letter o of echo.

The 49 refers to the 49th character of the quoted command which
points to the "e" at the end.  So the backslash before the last "@"
prevents sed from seeing that as the delimiter between the
replacement and the flags.  If you want a backslash, escape it:

  ...echo \1 \\@ge

or if it's a mistake, just remove it

  ...echo \1 @ge

-tim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.