From owner-freebsd-questions Fri May 31 9:54:19 2002 Delivered-To: freebsd-questions@freebsd.org Received: from wopr.caltech.edu (wopr.caltech.edu [131.215.103.10]) by hub.freebsd.org (Postfix) with ESMTP id F40AB37B400 for ; Fri, 31 May 2002 09:53:41 -0700 (PDT) Received: from wopr.caltech.edu (localhost.caltech.edu [127.0.0.1]) by wopr.caltech.edu (8.12.3/8.12.3) with ESMTP id g4VGlLPh035596; Fri, 31 May 2002 09:47:21 -0700 (PDT) (envelope-from mph@wopr.caltech.edu) Received: (from mph@localhost) by wopr.caltech.edu (8.12.3/8.12.3/Submit) id g4VGlKfA035595; Fri, 31 May 2002 09:47:20 -0700 (PDT) Date: Fri, 31 May 2002 09:47:20 -0700 From: Matthew Hunt To: j mckitrick Cc: Benoit Lacherez , freebsd-questions@FreeBSD.ORG Subject: Re: Why does 'sed' delete my input file? Message-ID: <20020531094720.C34758@wopr.caltech.edu> References: <20020531130029.B28925@dogma.freebsd-uk.eu.org> <20020531141421.A72043@bisclavret.iris33.ac-bordeaux.f> <20020531132211.A29199@dogma.freebsd-uk.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020531132211.A29199@dogma.freebsd-uk.eu.org>; from jcm@FreeBSD-uk.eu.org on Fri, May 31, 2002 at 01:22:11PM +0100 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:22:11PM +0100, j mckitrick wrote: > | cat file1 | sed 's/foo/bar/g' > file1 > > Perfect! I don't think that's guaranteed to work at all. There's no assurance that cat will have read then entire contents of file1 before the shell opens it for writing. wopr:~/tmp$ wc -l blah 164925 blah wopr:~/tmp$ ls -l blah -rw------- 1 mph mph - 6807485 May 31 09:42 blah wopr:~/tmp$ cat blah | sed 's/foo/bar/g' > blah wopr:~/tmp$ ls -l blah -rw------- 1 mph mph - 0 May 31 09:42 blah My shell is bash. -- Matthew Hunt * Eight lanes of shimmering cement from http://www.pobox.com/~mph/ * here to Pasadena! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message