There are different ways to convert a string from lowercase to uppercase or uppercase to lowercase. You can use awk, tr commands to convert a string in lowercase or uppercase in Linux bash shell.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
s="hello world" S="HELLOW WORLD" ## Using tr echo "$s" | tr '[:lower:]' '[:upper:]' ## Returns HELLO WORLD echo "$S" | tr '[:upper:]' '[:lower:]' ## Returns hello world ## Using awk echo "$s" | awk '{print toupper($0)}' ## Returns HELLO WORLD echo "$S" | awk '{print tolower($0)}' ## Returns hello world ## additional examples echo $s ## Returns hello world echo ${s^^} ## Returns HELLO WORLD echo ${s^} ## Returns Hello world echo ${s^^w} ## Returns hello World echo ${s^^[h,w]} ## Returns Hello World |