Lowercase to Uppercase

Inside a script I have 2 variables COMP=cy and PT=t. further down the same script I require at the same line to call those 2 variables the first time uppercase and after lowercase ${COMP}${PT}ACE,${COMP}${PT}ace. Can somebody help me

Thanks in advance

George Govotsis

There are a variety of ways to do what you suggest. The simplest is to create variables that the shell will convert to all uppercase or lowercase:

typeset -u COMP_UPPER PT_UPPER
typeset -l COMP_LOWER PT_LOWER

The variables above will always convert their values to uppercase or lowercase, respectively. Of course, you can also convert via other programs:

echo "$COMP" | tr '[a-z]' '[A-Z]'
echo "$COMP" | awk '{print toupper($0)}'

You get the idea.

#!/bin/ksh

a='foo'
typeset -uL1 b=${a}
echo "${b}${a#?}"

More on this here.

I guess the OP wanted the variable values to be capitalized - not the whole string to be UPPER-cased.
The OP will have to clarify!

I guess you can also use syntax as

print $VARIABLE|sed 'y/[a-z]/[A-Z]' 

or

tr "[:lower:]" "[:upper:]"

tr "[:upper:]" "[:lower:]"

i dont have any variable
i dont have any file

i just want to convert AJIT to ajit
can i do this in UNIX atraight away

@ajit.yadav83
There are plenty of examples above - you just have to change the echoing of a variable to echoing your string for example...