From owner-freebsd-hackers Mon Oct 1 4:55:48 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from alpha.dante.org.uk (alpha.dante.org.uk [193.63.211.19]) by hub.freebsd.org (Postfix) with ESMTP id 9EDFD37B403 for ; Mon, 1 Oct 2001 04:55:44 -0700 (PDT) Received: from pi.dante.org.uk ([193.63.211.70] helo=dante.org.uk) by alpha.dante.org.uk with esmtp (Exim 3.12 #4) id 15o1fR-0005LP-00; Mon, 01 Oct 2001 12:55:25 +0100 Message-ID: <3BB859AC.2192A711@dante.org.uk> Date: Mon, 01 Oct 2001 12:55:24 +0100 From: Konstantin Chuguev Organization: Delivery of Advanced Network Technology to Europe Ltd. X-Mailer: Mozilla 4.78 [en] (X11; U; SunOS 5.8 sun4u) X-Accept-Language: ru, en MIME-Version: 1.0 To: "Eugene L. Vorokov" Cc: "Daniel C. Sobral" , freebsd-hackers@FreeBSD.ORG Subject: Re: how to make 'for' understand two words as a single argument References: <200110011039.f91AdOD88292@bugz.infotecs.ru> <3BB855BB.D10C5030@newsguy.com> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG "Daniel C. Sobral" wrote: > "Eugene L. Vorokov" wrote: > > > > I have a script which is supposed to convert all filenames to lowercase > > recursively from current directory. It looks like: > > > > echo "Processing files" > > for i in `ls |grep [A-Z]`; \ > > do mv $i `echo $i |tr [A-Z] [a-z]`; echo $i;\ > > done; ls |grep [A-Z] | while read i; \ do mv $i `echo $i |tr [A-Z] [a-z]`; echo $i;\ done > > > for i in `find . -name "*" -type d -maxdepth 1`;\ > > do if [ $i != "." ]; then cd $i; echo "Processing sub-dir $i"; $0; cd ..; fi \ > > done; find . -name "*" -type d -maxdepth 1 | while read i; \ do if [ $i != "." ]; then cd $i; echo "Processing sub-dir $i"; $0; cd ..; fi \ done Be aware that the pipe will launch a child shell for the while loop, so any variables set inside the loop will get lost after 'done' And, of course, the output of the first part of the pipe should be one file name per line. -- * * Konstantin Chuguev Francis House * * Application Engineer 112 Hills Road * Tel: +44 1223 302992 Cambridge CB2 1PQ D A N T E WWW: http://www.dante.net United Kingdom To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message