From owner-freebsd-questions Wed Feb 26 9: 1:34 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 7375337B401 for ; Wed, 26 Feb 2003 09:01:33 -0800 (PST) Received: from arcturus.student.iastate.edu (arcturus.student.iastate.edu [64.113.65.15]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8841743FBD for ; Wed, 26 Feb 2003 09:01:30 -0800 (PST) (envelope-from kparz@arcturus.student.iastate.edu) Received: from arcturus.student.iastate.edu (localhost [127.0.0.1]) by arcturus.student.iastate.edu (8.12.7/8.12.7) with ESMTP id h1QH1MQd005047; Wed, 26 Feb 2003 11:01:22 -0600 (CST) (envelope-from kparz@arcturus.student.iastate.edu) Received: (from kparz@localhost) by arcturus.student.iastate.edu (8.12.7/8.12.7/Submit) id h1QH1Dtc005046; Wed, 26 Feb 2003 11:01:13 -0600 (CST) Date: Wed, 26 Feb 2003 11:01:13 -0600 From: Krzysztof Parzyszek To: Tijl Coosemans Cc: freebsd-questions@FreeBSD.ORG Subject: Re: cat Message-ID: <20030226170113.GA5008@arcturus.student.iastate.edu> Reply-To: kristof@swissmail.org References: <20030226175613.5e61f45e.tijl@ulyssis.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline In-Reply-To: <20030226175613.5e61f45e.tijl@ulyssis.org> User-Agent: Mutt/1.4i 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 Wed, Feb 26, 2003 at 05:56:13PM +0100, 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? Because the shell can open `filename' for writing (because of output redirection) and thus truncate it to 0 bytes before cat opens it for reading. Try cat filename | tr -d '\r' > filename.new instead. -- <>> kristof@swissmail.org 9/2/2002 <<> "If you can't convince them, confuse them" -- HS Truman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message