Monday, April 16, 2018

How to convert string to Uppercase and Lower case in Linux using awk and tr commands.



Lowercase to Uppercase:

Using awk command.
root@linuxserver:/root> echo santhosh | awk '{ print toupper($0)}'
SANTHOSH

Using tr command.
root@linuxserver:/root> echo santhosh | tr '[a-z]' '[A-Z]'
SANTHOSH


Uppercase to Lowercase:

Using awk command.
root@linuxserver:/root> echo SANTHOSH | awk '{ print tolower($0)}'
santhosh

Using tr command.
root@linuxserver:/root> echo SANTHOSH | tr '[A-Z]' '[a-z]'
santhosh

No comments:

Post a Comment