[Techtalk] lower to upper case

Wim De Smet kromagg at gmail.com
Tue Oct 9 09:26:08 UTC 2007


On 10/9/07, Miriam English <mim at miriam-english.org> wrote:
> 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?

I don't think it is simpler, but you could do the same thing with sed
instead of tr. I think that would be : sed 's/.*/\U&/'

So very similar to what you would do in vi. Also it's probably best to
always quote your variables, so instead of echo $file write echo
"$file".

greets,
Wim


More information about the Techtalk mailing list