bash convert string to uppercase code example
Example 1: bash how to convert text to lowercase or uppercase
tolower(string)
toupper(string)
awk '{print tolower($0)}' input_file
awk '{print toupper($3)}' input_file
Example 2: bash lowercase
Just use tr command to transform lowercase letters into uppercase as:
tr a-z A-Z < file.txt
echo 'HELLO' | tr A-Z a-z
Example 3: bash convert string to uppercase
var=hello
echo ${var''}
HELLO
echo ${var'}
Hello
var2=BYE
echo ${var2,}
bye
echo ${var2,,}
bYE
echo $var | tr 'a-z' 'A-Z'
HELLO