From owner-freebsd-questions Wed Feb 26 14:20:57 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 87EC237B401 for ; Wed, 26 Feb 2003 14:20:56 -0800 (PST) Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 24E5443F85 for ; Wed, 26 Feb 2003 14:20:50 -0800 (PST) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b176.otenet.gr [212.205.244.184]) by mailsrv.otenet.gr (8.12.6/8.12.6) with ESMTP id h1QMKgAC005727; Thu, 27 Feb 2003 00:20:44 +0200 (EET) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.7/8.12.7) with ESMTP id h1QMKYON090022; Thu, 27 Feb 2003 00:20:34 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.12.7/8.12.7/Submit) id h1QMK92J090005; Thu, 27 Feb 2003 00:20:09 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 27 Feb 2003 00:20:09 +0200 From: Giorgos Keramidas To: Tijl Coosemans Cc: freebsd-questions@FreeBSD.ORG Subject: Re: cat Message-ID: <20030226222009.GB78804@gothmog.gr> References: <20030226175613.5e61f45e.tijl@ulyssis.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030226175613.5e61f45e.tijl@ulyssis.org> 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 2003-02-26 17:56, Tijl Coosemans wrote: > I want to remove CRs from text files so what I did is this: > > cat filename | tr -d '\r' > filename > > However, I often end up with an empty file. Just out of > interest, somebody who knows why that is? The shell opens filename for input and then attempts to reopen it once more for output, at the same time. The '>' operator truncates the file. You will get much better and more predictable results if you use a temporary file to store the intermediate result of tr(1): $ tr -d '\r' < filename > filename.tmp $ mv filename.tmp filename - Giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message