LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-09-2010, 12:10 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 37
How to change Case of a string(BASH Scripting)?


Is there any inbuilt functionality in Unix shell script so that i can able to convert lower case string input to an upper case?

I dont want to use high level languages like java,python or perl for doing the job.
 
Old 07-09-2010, 12:25 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Code:
tr a-z A-Z filename
 
1 members found this post helpful.
Old 07-09-2010, 12:26 AM   #3
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by pinga123 View Post
Is there any inbuilt functionality in Unix shell script so that i can able to convert lower case string input to an upper case?

I dont want to use high level languages like java,python or perl for doing the job.
Try this:

Code:
$ echo 'my string' | tr 'a-z' 'A-Z'
MY STRING
 
Old 07-09-2010, 12:29 AM   #4
loftus49
Member
 
Registered: May 2010
Location: Phoenix
Distribution: Ubuntu, CentOS5, Fedora, Mint, MX Linux
Posts: 178
Blog Entries: 1

Rep: Reputation: 20
I believe you can try "cat <name of file> | tr 'a-z' 'A-Z'" (without the < > or " ") to go from lower case to uppercase. Consequently "cat <name of file> | tr 'A-Z' 'a-z'" would take you from upper case to lower case.

cat myfile | tr 'a-z' 'A-Z'
 
Old 07-09-2010, 12:31 AM   #5
wizman56
LQ Newbie
 
Registered: Jul 2010
Location: Kuala Lumpur
Distribution: Redhat
Posts: 3

Rep: Reputation: 0
Ok, simply put you could do this:

export lower=somevalue
export lower=`echo $lower | tr 'a-z' 'A-Z'`
 
  


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
bash scripting capitalizing first letter or each word in a string hypexr Programming 6 06-16-2011 09:58 AM
[SOLVED] Bash scripting, separating variable from string text emmalg Linux - Newbie 3 06-26-2009 03:31 AM
case problems when scripting in bash camilla_darling Programming 2 03-19-2009 12:37 PM
bash scripting...is a file also a string? Daravon Linux - Newbie 3 09-03-2008 03:38 AM
change case of a string (TOUPPER) in shell script raees Linux - Software 3 05-03-2005 02:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:28 PM.

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