LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to change Case of a string(BASH Scripting)? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-case-of-a-string-bash-scripting-818822/)

pinga123 07-09-2010 12:10 AM

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.

pixellany 07-09-2010 12:25 AM

Code:

tr a-z A-Z filename

Telengard 07-09-2010 12:26 AM

Quote:

Originally Posted by pinga123 (Post 4027958)
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


loftus49 07-09-2010 12:29 AM

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'

wizman56 07-09-2010 12:31 AM

Ok, simply put you could do this:

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


All times are GMT -5. The time now is 08:07 AM.