tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Using n

Two easy scripting questions ▻

syntax question

In article <883ajb$vk0$1@pravda.ucr.edu>, chris ulrich <cdu@jawa.> wrote:
>  This will do bad things to files with spaces in the names.

Yes.

>                                                              THe
>correct way to deal with this is
>for a in * ; do mv "$a" `echo "$a" | tr a-z A-Z` ; done

No, unless you have a non-standard IFS.  (Did you try it?)

    for a in *; do mv "$a" "`echo "$a" |tr a-z A-Z`"; done

<ob-rc-comparison>
As usual, rc removes some of the clutter, but it's still a little tricky
to get this completely right.  I think my preferred version is this.

    ifs=() for (a in *) { mv $a `{printf $a |tr a-z A-Z} }

</ob-rc-comparison>

Tim.
--
Tim Goodwin   | "If you don't know what closures are, you probably don't
Leicester, UK | want to know what closures are." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: syntax question
Date: 14 Feb 2000 10:12:14 -0000
Message-ID: <888kek$sdd$1@ltpcg.star.le.ac.uk>
References: <38A40D1B.2559E390@bentley.com>
  <38A41C58.53C92C3E@inka.de> <883ajb$vk0$1@pravda.ucr.edu>

△ comp.unix.shell △

◅ Using n

Two easy scripting questions ▻