LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-03-2005, 12:39 PM   #1
raees
Member
 
Registered: Nov 2003
Posts: 65

Rep: Reputation: 15
change case of a string (TOUPPER) in shell script


How can I change case of a string (TOUPPER) in shell script , is there a utility that I can use ?
 
Old 05-03-2005, 12:55 PM   #2
slightcrazed
Member
 
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Rep: Reputation: 30
tr -c UPPERCASE lowercase </file/to/modify

That *should* do the trick... been a while since I used tr in a script. Change UPPERCASE and lowercase to the string you want to replace. ie:

tr -c I i </home/slight/testfile

will change all of the uppercase I into lowercase i in the file /home/slight/testfile.

Hope that helps.

slight
 
Old 05-03-2005, 02:09 PM   #3
raees
Member
 
Registered: Nov 2003
Posts: 65

Original Poster
Rep: Reputation: 15
tr "[:upper:]" "[:lower:]" < file
or
echo "whatever" | tr "[:upper:]" "[:lower:]"

is the correct syntax
 
Old 05-03-2005, 03:13 PM   #4
slightcrazed
Member
 
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Rep: Reputation: 30
correct, but only if you want to change ALL uppercase characters to lowercase. If you're looking for a specific string or a single character then you can use the -c (change) option.

slight
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script - String Replacement revof11 Programming 7 11-29-2005 07:38 AM
(shell script) string parsing kuru Programming 4 09-12-2005 08:59 PM
Shell script to find a particular string Prasun1 Linux - General 5 08-30-2005 10:23 AM
help changing case on arguments to bourne shell script Maldain Programming 2 05-03-2005 11:18 AM
exploding string into individual characters using a shell script farmerjoe Programming 9 10-13-2004 04:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration