[Gllug] Changing case on filenames

Simon Stewart sms at lateral.net
Tue Mar 5 11:07:24 UTC 2002


On Tue, Mar 05, 2002 at 12:38:09AM +0000, Tom Gilbert wrote:
> * Rob Andrews (rob at impure.org.uk) wrote:
> > [04-Mar-2002 21:36.23 (GMT) / Gordon Joly]
> >  > >This wonderful technique can be built on:-
> >  > >for i in *; do
> >  > >mv $i `echo $i | tr 'A-Z' 'n-za-m'`
> >  > >done
> >  > which shell?
> > 
> > My suspicion tells me that won't work, since $ will be quoted directly due
> > to the single quotes.
> 
> Those aren't single quotes, those are backticks, which act as double
> quotes when it comes to variable substitution.
> 
> > Additionally, the internal single quotes are unescaped, so they'll break.
> 
> No they won't :)

You're right, but the filenames should be quoted:

mv "$i" "`echo $i | tr 'A-Z' 'n-z-a-m'`"

is more safe. As someone on this list (tet?) likes to point out
occasionally.

Cheers,

Simon

-- 
Actually Perl *can* be a Bondage & Discipline language but it's unique
among such languages in that it lets you use safe words.
    -- Piers Cawley

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list