From owner-freebsd-hackers Mon Oct 1 4:35:43 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from newsguy.com (smtp.newsguy.com [209.155.56.71]) by hub.freebsd.org (Postfix) with ESMTP id D3FE737B410 for ; Mon, 1 Oct 2001 04:34:17 -0700 (PDT) Received: from newsguy.com (ppp232-bsace7002.telebrasilia.net.br [200.181.81.232]) by newsguy.com (8.9.1a/8.9.1) with ESMTP id EAA98439; Mon, 1 Oct 2001 04:33:47 -0700 (PDT) Message-ID: <3BB855BB.D10C5030@newsguy.com> Date: Mon, 01 Oct 2001 08:38:35 -0300 From: "Daniel C. Sobral" X-Mailer: Mozilla 4.77 [en] (Win98; U) X-Accept-Language: en,pt-BR,pt,en-GB,en-US,ja MIME-Version: 1.0 To: "Eugene L. Vorokov" Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: how to make 'for' understand two words as a single argument References: <200110011039.f91AdOD88292@bugz.infotecs.ru> Content-Type: text/plain; charset=us-ascii 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 "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; > for i in `find . -name "*" -type d -maxdepth 1`;\ > do if [ $i != "." ]; then cd $i; echo "Processing sub-dir $i"; $0; cd ..; fi \ > done; > > It works fine unless some file or directory has a space in it's name. > It this case each word is interpreted as a separate argument by 'for' > and script doesn't find files. Any way using `` won't work. for i in a "b c" d works, for instance, but there is not way that I know of that you can control the output this way using ``. OTOH, try: find . -type d -maxdepth 1 -print -exec mv {} `echo {} | tr [A-Z] [a-z]` \; -- Daniel C. Sobral (8-DCS) dcs@newsguy.com dcs@freebsd.org capo@the.secret.bsdconspiracy.net wow regex humor... I'm a geek To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message