LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   change case of a string (TOUPPER) in shell script (https://www.linuxquestions.org/questions/linux-software-2/change-case-of-a-string-toupper-in-shell-script-319736/)

raees 05-03-2005 12:39 PM

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 ?

slightcrazed 05-03-2005 12:55 PM

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

raees 05-03-2005 02:09 PM

tr "[:upper:]" "[:lower:]" < file
or
echo "whatever" | tr "[:upper:]" "[:lower:]"

is the correct syntax

slightcrazed 05-03-2005 03:13 PM

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


All times are GMT -5. The time now is 05:41 AM.