Changing case of file names?

Andrew Kirkpatrick andykirk at
Thu May 4 02:05:50 CST 2006

Jason Tan wrote:
> for f in `ls -1`; do mv $f `echo $f|tr  a-z A-Z ` ; done

My biggest gripes with shell are the way it treats whitespace, quoting 
and does variable substitution as raw text. That line will malfunction 
if any of the filenames have embedded spaces, but this will work:

ls | while read f; do mv "$f" "`echo $f|tr A-Z a-z`"; done

However it still can't handle filenames with leading or trailing spaces, 
and its at this point I conclude shell is a toy language that sometimes 
bites :)


More information about the linuxsa mailing list