From owner-freebsd-questions Tue Dec 25 18:41:51 2001 Delivered-To: freebsd-questions@freebsd.org Received: from hawk.prod.itd.earthlink.net (hawk.mail.pas.earthlink.net [207.217.120.22]) by hub.freebsd.org (Postfix) with ESMTP id 088F237B417 for ; Tue, 25 Dec 2001 18:41:49 -0800 (PST) Received: from sdn-ar-007dcwashp216.dialsprint.net ([63.178.90.130] helo=moo.holy.cow) by hawk.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16J40p-0004J4-00; Tue, 25 Dec 2001 18:41:48 -0800 Received: by moo.holy.cow (Postfix, from userid 1001) id A6DD350E29; Tue, 25 Dec 2001 21:42:42 -0500 (EST) Date: Tue, 25 Dec 2001 21:42:42 -0500 From: parv To: Joe & Fhe Barbish Cc: FBSD Questions Subject: Re: Dos -> Unix end-of-line conversion Message-ID: <20011225214242.B55635@moo.holy.cow> Mail-Followup-To: Joe & Fhe Barbish , FBSD Questions References: <20011226113216.A24782@grimoire.chen.org.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ; from barbish@a1poweruser.com on Tue, Dec 25, 2001 at 08:51:01PM -0500 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 in message , wrote Joe & Fhe Barbish thusly... > > How can I get this command to roll through a directory tree processing all > the files to feed this $ tr -d '\r' < oldfile > newfile command converting > dos2unix or unix2dos? There is a dos2unix / unix2dos port but it only does > one file at a time. you definitely need to see find(1), sh(1), test(1). in the meantime, if you are using ksh/sh/bash this should work w/ not much fiddling (partially tested in bash)... find -type f | while read Old do # this needs to be more sophisticated; but something is better than # nothing # if ( ! file "$Old" | grep 'text' >/dev/null 2>&1 ) \ || [ ! -f "$Old" -a -r "$Old" -a ! -L "$Old" ] then echo '* ' $Old 'may not be a text file or not readable; skipping...' continue fi echo ' -- sanitizing ' $Old tr -d '\r' < "$Old" > "${Old}.changed" # optionally remove old files, keep only changed ones # #mv -f "${Old}.changed" "$Old" done -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message