Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Neglect Case Sensitivity in Unix?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi There!

Does anyone know how to make your script non case sensitive.
For example I want the user to input a specific filename to be manipulated in a directory. But the filename have both small and capital letters. How can I neglect the case so that no error message will be given and I will also be able to access the specific file?

Thanks!
kitzzz
 
What language/shell are you writing your script in?

Which version of UNIX are you running? Mike
______________________________________________________________________
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Yup - use tr to convert a filename into upper case, then compare it against the uppercase name you got from the user. Mike
______________________________________________________________________
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Here's a simple example of 'tr'

So if you want to compare your filename against that which the user enters, you'll have to do likewise with the filename variable that you use.

#! /bin/sh

echo "\nEnter file name: \c"
read ANSWER
echo "Filename was to converted to:\
`echo $ANSWER|tr '[:lower:]' '[:upper:]'`\n"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top