[Techtalk] lower to upper case

R. Daneel Olivaw linuxchix at r-daneel.com
Tue Oct 9 06:16:24 UTC 2007


Hi there,

> It worked, and was a lot easier than renaming the 36 files by hand,
> but it seemed to me that there must be a much simpler way using a
> loop and expressions:
> 
> for file in *
> do
> 	mv $file `echo $file | tr '[a-z]' 'A-Z'`
> done
> 
> In my text editor I'd simply replace each filename with \U& but that 
> isn't possible directly in bash.
> 
> Is there an even simpler way?

The loop you wrote is the simplest way I see, tr also uses classes, so
you could have written:

for file in *
do
  mv "${file}" "$(echo ${file} | tr '[:lower:]' '[:upper:]')"
done

bye,

R. Daneel Olivaw,
The Human Robot Inside.


More information about the Techtalk mailing list