From owner-freebsd-questions Fri May 31 5:13:10 2002 Delivered-To: freebsd-questions@freebsd.org Received: from rhadamanth.submonkey.net (pc1-card5-0-cust12.cdf.cable.ntl.com [80.3.216.12]) by hub.freebsd.org (Postfix) with ESMTP id B1B1937B400 for ; Fri, 31 May 2002 05:13:05 -0700 (PDT) Received: from setantae by rhadamanth.submonkey.net with local (Exim 3.36 #1) id 17DlFz-0004a4-00; Fri, 31 May 2002 13:11:47 +0100 Date: Fri, 31 May 2002 13:11:47 +0100 From: Ceri Davies To: j mckitrick Cc: freebsd-questions@freebsd.org Subject: Re: Why does 'sed' delete my input file? Message-ID: <20020531121147.GA17428@submonkey.net> Mail-Followup-To: Ceri Davies , j mckitrick , freebsd-questions@freebsd.org References: <20020531130029.B28925@dogma.freebsd-uk.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020531130029.B28925@dogma.freebsd-uk.eu.org> User-Agent: Mutt/1.3.99i 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 On Fri, May 31, 2002 at 01:00:29PM +0100, j mckitrick wrote: > > This is a simple question, but I can't find the answer. The Daemonnews > article that seems to answer it is missing the graphics with the > screenshots. > > If I want to replace all occurrences of 'foo' in a file, this is what I > tried: > > sed s/foo/bar/g file1 > file1 > > But this deletes (overwrites?) the contents of the file. What did I do > wrong? Do you end up with a zero length file ? I *think* this is because the shell truncates file1 before calling sed, so that all sed has to work with is an empty file. I'm probably wrong though. Ceri -- you can't see when light's so strong you can't see when light is gone To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message