tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Seasoned users

find without subdirs ▻

sed and quotes

In article <39108F0F.B5852A90@t-online.de>,
Ulrich Jankrift  <ulrich.jankrift@t-online.de> wrote:
>changing a single line with:
>sed -e "534c\
>                Value =\"a.b.c\""  file
>
>works very well !!

Not as you've posted it: sed needs to see `c\', but---inside double
quotes---you're backslash is swallowed by the shell as a line
continuation.

>In single-quotes the Variables will not substituted and in double-quotes
>the "change" will not work. There must be an easy solution to it.

So you just use both.

I think this is what you're after:

    sed -e "$ZEILE"'c\
                      Value = "'"$VAR"'"' file

There are other variants that will work.  My personal rules, when
combining different quoting forms like this, are to put all the literal
text inside single quotes, and to not use backslashes.

Tim.
--
Tim Goodwin   | "If you don't know what closures are, you probably don't
Leicester, UK | want to know what closures are." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: sed and quotes
Date: 11 May 2000 10:57:26 +0100
Message-ID: <8fe06s$73o$1@ltpcg.star.le.ac.uk>
References: <39108F0F.B5852A90@t-online.de>

△ comp.unix.shell △

◅ Seasoned users

find without subdirs ▻