From owner-freebsd-questions Wed Feb 26 23:59:57 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id XAA11593 for questions-outgoing; Wed, 26 Feb 1997 23:59:57 -0800 (PST) Received: from mail.EUnet.hu (www.eunet.hu [193.225.28.100]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id XAA11587 for ; Wed, 26 Feb 1997 23:59:54 -0800 (PST) Received: by mail.EUnet.hu, id IAA10526; Thu, 27 Feb 1997 08:59:47 +0100 Received: (from zgabor@localhost) by CoDe.hu (8.7.5/8.7.3) id PAA00512 for freebsd-questions@freebsd.org; Wed, 26 Feb 1997 15:20:11 +0100 (MET) From: Zahemszky Gabor Message-Id: <199702261420.PAA00512@CoDe.hu> Subject: Re: any sh or bash gurus out there? To: freebsd-questions@freebsd.org (FreeBSD questions) Date: Wed, 26 Feb 1997 15:20:10 +0100 (MET) In-Reply-To: from Dan Busarow at "Feb 25, 97 07:10:42 pm" X-Mailer: ELM [version 2.4ME+ PL11 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > On Tue, 25 Feb 1997, Randy DuCharme wrote: > > I'm stuck again. I have a couple hundred 'DOS' text files that I need > > to make use of. I need to get rid of that annoying '^M' at the end > > of each line. I can kill it like this... > > for filename in `find . -name "*.txt"` > do > tr -d '\015' < filename > filename.new ; mv filename.new filename > done 1) In the "tr" line, change any filename to $filename 2) If you have so many .txt files, that your commnand line is overrunning, a better method would be: find . -name "*.txt" -print | while read filename do tr -d '\015' < $filename > $filename.new ; mv $filename.new $filename done Of course, if you have a file with x.txt, and x.txt.new, you've lost. (And with newer finds, you don't need "-print". It's only for compatibility.) > Plug in an appropriate expression for selecting the files and run from > the root of the tree. Gabor