From owner-freebsd-questions Mon Sep 24 18:43:11 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 5B35137B414 for ; Mon, 24 Sep 2001 18:43:08 -0700 (PDT) Received: from hades.hell.gr (patr530-b005.otenet.gr [195.167.121.133]) by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id f8P1h4c27161; Tue, 25 Sep 2001 04:43:05 +0300 (EEST) Received: (from charon@localhost) by hades.hell.gr (8.11.6/8.11.6) id f8P1gjd02755; Tue, 25 Sep 2001 04:42:45 +0300 (EEST) (envelope-from charon@labs.gr) Date: Tue, 25 Sep 2001 04:42:45 +0300 From: Giorgos Keramidas To: Mark Rowlands Cc: freebsd-questions@FreeBSD.ORG Subject: Re: silly sed question Message-ID: <20010925044245.B2359@hades.hell.gr> References: <20010924115816.EE2F637B418@hub.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20010924115816.EE2F637B418@hub.freebsd.org> User-Agent: Mutt/1.3.22.1i X-GPG-Fingerprint: C1EB 0653 DB8B A557 3829 00F9 D60F 941A 3186 03B6 X-URL: http://labs.gr/~charon/ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Mark Rowlands 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