Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Feb 1997 15:20:10 +0100 (MET)
From:      Zahemszky Gabor <zgabor@CoDe.hu>
To:        freebsd-questions@freebsd.org (FreeBSD questions)
Subject:   Re: any sh or bash gurus out there?
Message-ID:  <199702261420.PAA00512@CoDe.hu>
In-Reply-To: <Pine.UW2.3.95.970225185923.14997C-100000@cedb> from Dan Busarow at "Feb 25, 97 07:10:42 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702261420.PAA00512>