Abhinav Abhinav - 4 years ago 645
Bash Question

character case conversion Uppercase to Lower and vice versa

I was trying to convert the lowercase characters to uppercase. I came across various alternatives like one listing at the StackOverflow question. However, What i saw that these are just printed. I want to save it to another variable which i can use later.
Can anyone tell how i can achieve this?

Answer Source

Your input is $a. The new variable is $b.
(borrowed from here written by @ghostdog74)

using tr:

b=$( tr '[A-Z]' '[a-z]' <<< $a)

if you use tcsh, then use echo instead of <<<:

set b=`echo "$a" | tr '[A-Z]' '[a-z]'`
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download