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.


The syntax to convert an input string to lowercase using tr command is

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.



In the following script, we take a string in s, and convert it to lowercase using tr command.

s="HELLO World"
lowerstr=$(echo $s | tr '[:upper:]' '[:lower:]')
echo "Original  String : $s"
echo "Lowercase String : $lowerstr"


Original  String : HELLO World
Lowercase String : hello world


In this Bash Tutorial, we have learnt how to convert a string to lowercase in Bash using tr command.