How convert lowercase or uppercase

It will only accept one argument where it should be upper or lowercase. if user choose to convert filnames to upper case than it should convert to upper or vice versa. if no action taken by the user then should not do anything

any of the files in the current directory.

pls post what you've got and where you're having problems.


if test $# -ne 1
then
   echo "wrong number of args: $0 flags[-l][-u] "
   return
fi

if test $1 = "-l"
then
    tr "[A-Z]" "[a-z]" < file1
elif test $1 = "-u"
then
    tr "[a-z]" "[A-Z]" < file1
else
    echo "wrong options: [-l][-u]"
fi

Use this script to change case name of all files in the current directory as,

#!/bin/sh
# Muthukumar
# Script to change name from upper to lower / lower to upper
# <usage> [lower | upper]

if [[ $# -ne 1 ]]
then
  echo "Usage: $0 [lower|upper]"
  exit 1
fi

for file in `find . -type f`
do
  if [[ "$1" = "lower" ]]
  then
    mv $file $(echo $file | tr [[:upper:]] [[:lower:]])
  elif [[ "$1" = "upper" ]]
  then
    mv $file $(echo $file | tr [[:lower:]] [[:upper:]])
  else
    echo "Unknown option $1. Use upper | lower"
    exit 1
  fi
done

exit 0
## END ##

HTH.

If you want to ensure arguments past into your program are in the correct case, you should use typeset -u to convert to uppercase and typeset -l to convert to all lowercase.

hello i need your help