#! /Bin/sh
Files = ""
Trcase = ""
EXT = ""
Opt = No
# Gets called when a conversion fails
Error_msg ()
{
_ Filename = $1
Echo "'basename $ 0': Error The Conversion failed on $ _ filename"
}
If [$ #-EQ 0]
Then
Echo "for more info try 'basename $ 0' -- help"
Exit 1
Fi
While [$ #-GT 0]
Do
Case $1 in
-U) trcase = upper
EXT = ". UC"
Opt = Yes
Shift
;;
-L) trcase = lower
EXT = ". LC"
Opt = Yes
Shift
;;
-Help) echo "convert a file (Files) to uppercase from lowercase"
Echo "convert a file (Files) from lowercase to uppercase"
Echo "will convert all characters according to the specified command option ."
Echo "where option is"
Echo "-l convert to lowercase"
Echo "-u convert to uppercase"
Echo "The originak files is not touched, a new file will be created with either a. UC or. LC extension"
Echo "Usage: $0-[l] [u] File"
Exit 0
;;
-*) Echo "Usage: 'basename $ 0'-[l] [u] File"
Exit 1
;;
# Collect the files to process
*) If [-F $2]
Then
# Add the filenames to a variable list
Files = $ Files "" $1
Else
Echo "'basename $ 0': error can not find the file $1"
Fi
Shift
;;
Esac
Done
# No options given... help the user
If ["$ Opt" = "no"]
Then
Echo "'basename $ 0': error you need to specify an option no action taken"
Echo "Try 'basename $ 0' -- help"
Exit 1
Fi
# Now read in all files
For Loop in $ files
Do
Case $ trcase in
Lower) Cat $ loop | TR "[A-Z]" "[A-Z]"> $ loop $ ext
If [$? ! = 0]
Then
Error_msg $ Loop
Else
Echo "converted file call $ loop $ Ext"
Fi
;;
Upper) Cat $ loop | TR "[A-Z]" "[A-Z]"> $ loop $ ext
If [$? ! = 0]
Then
Error_msg $ Loop
Else
Echo "converted file call $ loop $ Ext"
Fi
;;
Esac
Done