Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Sep 2001 04:42:45 +0300
From:      Giorgos Keramidas <charon@labs.gr>
To:        Mark Rowlands <mark.rowlands@minmail.net>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: silly sed question
Message-ID:  <20010925044245.B2359@hades.hell.gr>
In-Reply-To: <20010924115816.EE2F637B418@hub.freebsd.org>
References:  <20010924115816.EE2F637B418@hub.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Mark Rowlands <mark.rowlands@minmail.net> wrote:
> I have a string
> 
> TARGETS='blob1 blob2 blob3'
> 
> and I wish to use to change this to 
> 
> TARGETS='blob1 blob2 blob3 blob4'    
> 
> for a multitude of files.
> 
> I am having problems with the quotes
> 
> sed -e  '/^TARGETS  s/'$/blob4'/'  myfile
> 
> ie find the line that begins with TARGETS and on that line swap the ending 
> single quote with blob4 and a single quote
> 
> is what I want to write and for sed to DWIM.....
> 
> I have tried escaping quotes in various places, double quotes and the like 
> but the correct incantation escapes me.......can anyone help

You are probably being bitten by TCSH's stupid quoting, which I NEVER actually
managed to get the grip of.  I tried testing this on sh(1), and here's what I
came up with:

	$ cat myfile
	TARGETS='blob1 blob2 blob3'
	$ sed -e "/^TARGETS/ s/\'$/ blob4\'/" myfile
	TARGETS='blob1 blob2 blob3 blob4'

-giorgos


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010925044245.B2359>