Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 28th, 2006, 3:03 AM   #1
Phonetic
Newbie
 
Join Date: Nov 2006
Posts: 5
Rep Power: 0 Phonetic is on a distinguished road
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.
Phonetic is offline   Reply With Quote
Old Nov 28th, 2006, 3:13 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
tr a-z A-Z, without the classes. Standard input to standard output, so sandwich it in there.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 30th, 2006, 2:21 PM   #3
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
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:]'`
jim mcnamara is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:45 PM.

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