Bash Script - Convert / Change string from Lower Case to Upper Case

Copy any of the following code in a .sh file and Execute the script.


1.echo $1 | awk '{print toupper($1)}'

2.echo $1 | tr "[:lower:]" "[:upper:]"

3.echo $1 | sed y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/

4.echo $1 | tr '[a-z]' '[A-Z]'

5.echo "${1^^}"



Let the code in test.sh

#./test.sh testing
TESTING

o/p as shown....

Note:-It's easy to change the above codes to change Uppercase to Lowercase. Just test it...

This entry was posted by Arun Ghosh. Bookmark the permalink.