Convert String to Lowercase
To convert a string to lowercase in Bash, use tr command. tr stands for translate or transliterate. With tr command we can translate uppercase characters, if any, in the input string to lowercase characters.
Syntax
The syntax to convert an input string to lowercase using tr command is
</>
                        Copy
                        tr '[:upper:]' '[:lower:]'tr command takes two two sets of characters as arguments.
With the above expression, if there are any uppercase characters in the given string, then tr converts it to lowercase.
Example
In the following script, we take a string in s, and convert it to lowercase using tr command.
Example.sh
</>
                        Copy
                        s="HELLO World"
lowerstr=$(echo $s | tr '[:upper:]' '[:lower:]')
echo "Original  String : $s"
echo "Lowercase String : $lowerstr"Output
Original  String : HELLO World
Lowercase String : hello worldConclusion
In this Bash Tutorial, we have learnt how to convert a string to lowercase in Bash using tr command.
