Uppercase to lowercase and vice versa

shell script to convert file names from UPPERCASE to lowercase file names or vice versa in linux
anybody please help me out!!!!

# bash --version
GNU bash, version 4.1.9(2)-release (i386-portbld-freebsd7.3)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


# cat script
#!/bin/bash
if [ ${#} -eq 0 ];then
        echo "Usage $0 [string]"
        exit
fi

for ((i=0;i<${#1};i++))
do
        char=${1:$i:1}
        case $char in
                [a-z]) new_string=${new_string}${char^};;
                [A-Z]) new_string=${new_string}${char,};;
                    *) new_string=${new_string}${char} ;;
        esac
done
echo In: \""$1"\"   Out: \""$new_string"\"

# /temp/script
Usage /temp/script [string]

# /temp/script "TeSt StR1Ng?"
In: "TeSt StR1Ng?" Out: "tEsT sTr1nG?"
#!/bin/ksh

if [[ $# != 1 ]]; then
   echo "Usage $0 [string]"
   exit 1
fi

instr=$1
typeset -u ustr=$1
typeset -l lstr=$1

echo "IN: $instr  UPPER: $ustr  LOWER: $lstr"

exit 0
tr '[:lower:][:upper:]' '[:upper:][:lower:]'
echo "this is small case" | tr '[[:lower:]]' '[[:upper:]]'
THIS IS SMALL CASE

The syntax for a tr character class uses single brackets not double; tr does not use regular expressions. If you are unconvinced, try the following:

echo '[abc]' | tr -d '[[:lower:]]'

and compare the result to

echo '[abc]' | tr -d '[:lower:]'

which is equivalent to the following sed, which does use regular expressions

echo '[abc]' | sed 's/[[:lower:]]//g'

In your original test case, it only appears to work because '[' in the first string is matched by an identical '[' in the second, so that the translisteration does not change the result (same for ']').

Regards,
Alister