1827894 Members
1908 Online
109969 Solutions
New Discussion

Re: uppercase

 
SOLVED
Go to solution
Andrej Vavro
Frequent Advisor

uppercase

One more syntax question:
I need to switch a text to uppercase in bash script.

VARIABLE='abcd'

I need to work with 'ABCD'


Regards,
Andrej
4 REPLIES 4
Francisco J. Soler
Honored Contributor
Solution

Re: uppercase

Hi, Andrej

VARIABLE=`echo $VARIABLE | tr [a-z] [A-Z]`

Best Regards.
Frank.
Linux?. Yes, of course.
Francisco J. Soler
Honored Contributor

Re: uppercase

Hi, Andrej,
Be careful with the quotation, copy and paste because they aren't normal quotes. This quotes doing an execution and the result is returned to the shell.
Linux?. Yes, of course.
Jean-Louis Phelix
Honored Contributor

Re: uppercase

hi

tr is the right command, but I just wanter to add that using classes is somtime more efficient :

echo $VAR | tr '[:lower:]' '[:upper:]'

There a a lot of classes ...

Regards.
It works for me (© Bill McNAMARA ...)
John Meissner
Esteemed Contributor

Re: uppercase

I had to do this except go to lowercase... but below is what you want

variable=$(cat file | awk '{print toupper($1)}')
echo $variable
All paths lead to destiny