bash convert string to lowercase code example
Example 1: bash transform uppercase to lowercase
Just use tr command to transform lowercase letters into uppercase as:
tr a-z A-Z < file.txt #transforms letters into uppercase in a file
echo 'HELLO' | tr A-Z a-z
Example 2: 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 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
Example 4: bash variable lowercase
a=DHCP
echo "${a,,}"
dhcp