Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 Oct 2001 12:55:24 +0100
From:      Konstantin Chuguev <Konstantin.Chuguev@dante.org.uk>
To:        "Eugene L. Vorokov" <vel@bugz.infotecs.ru>
Cc:        "Daniel C. Sobral" <dcs@newsguy.com>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: how to make 'for' understand two words as a single argument
Message-ID:  <3BB859AC.2192A711@dante.org.uk>
References:  <200110011039.f91AdOD88292@bugz.infotecs.ru> <3BB855BB.D10C5030@newsguy.com>

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3BB859AC.2192A711>