This tutorial covers how to convert a string to lowercase in the bash script file.

For example, If the input string contains the “Hello World Welcome,” the output will be “hello world welcome.”

There are multiple ways to convert a string to lowercase based on bash type and version.

  • using the tr command

tr is called a translator, a command in Unix used to translate from one format to another.

here is the syntax.

tr input_format output_format

Here is a shell script for converting to lowercase

message="Hello World, Welcome."
echo "$message" | tr '[:upper:]' '[:lower:]'


hello world, welcome.

Another way to replace the above code

message="Hello World, Welcome."
echo "$message" | tr 'A-Z' 'a-z'

tr command works with ASCII and does not work with UTF characters.

  • using the awk command the string converts to lowercase using the awk command to lower function combined with the awk command to result in lower case string. The result is input to the echo command using the pipe operator.
message="Hello World, Welcome"
echo "$message" | awk '{print tolower($0)}'

This is the best that works with ASCII and UTF characters.

  • in bash 4.0 version bash 4.0 provides string inbuilt in manipulation utilities. Adding two commas to a string makes a string a lowercase string.
message="Hello World, Welcome"
echo "${message,,}"
echo "${message}"
  • using Perl in the bash script

print lc with Perl makes a string in lowercase letters

echo "$message" | perl -ne 'print lc'