Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   Translating upper and lowercase (http://www.programmingforums.org/showthread.php?t=12030)

Phonetic Nov 28th, 2006 3:03 AM

Translating upper and lowercase
 
Hey there I was wondering how to make it so that whenever someone enters a variable that i can have that variable universal so I dont have to worry about "RANDOM" or "random" being entered and they're both read the same way.

I remember seeing a simple tr [:upper:] [:lower:] command, or something like that, but I can't find an example or explanation of the statement anywhere.

Anyway, help is always appreciated. Thanks for the time spent reading this.

DaWei Nov 28th, 2006 3:13 AM

tr a-z A-Z, without the classes. Standard input to standard output, so sandwich it in there.

jim mcnamara Nov 30th, 2006 2:21 PM

On a POSIX-compliant unix, tr supports POSIX classes -- those [:upper:] things.
:

echo "enter a word \c"
read aword
aword=`echo "$aword" | tr -s '[:lower:]' '[:upper:]'`



All times are GMT -5. The time now is 3:53 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC