From owner-freebsd-hackers Mon Oct 1 4:57: 7 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from pcwin002.win.tue.nl (pcwin002.win.tue.nl [131.155.71.72]) by hub.freebsd.org (Postfix) with ESMTP id 3522137B40E for ; Mon, 1 Oct 2001 04:57:03 -0700 (PDT) Received: (from stijn@localhost) by pcwin002.win.tue.nl (8.11.6/8.11.4) id f91BuZq39371; Mon, 1 Oct 2001 13:56:35 +0200 (CEST) (envelope-from stijn) Date: Mon, 1 Oct 2001 13:56:35 +0200 From: Stijn Hoop To: "Daniel C. Sobral" Cc: "Eugene L. Vorokov" , freebsd-hackers@freebsd.org Subject: Re: how to make 'for' understand two words as a single argument Message-ID: <20011001135635.A39309@pcwin002.win.tue.nl> References: <200110011039.f91AdOD88292@bugz.infotecs.ru> <3BB855BB.D10C5030@newsguy.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3BB855BB.D10C5030@newsguy.com>; from dcs@newsguy.com on Mon, Oct 01, 2001 at 08:38:35AM -0300 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 On Mon, Oct 01, 2001 at 08:38:35AM -0300, 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; > > 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 ``. Yes there is: set IFS to only contain a newline beforehand. That's my local hack, your way is probably better :) --Stijn -- "I used to think I was indecisive, but now I'm not so sure." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message