How to convert string to lower case
There are several ways to convert a string from uppercase to lowercase in Bash:
-
Use tr:
[tum@ezylinux ~]$ echo 'Hello World!' | tr '[:upper:]' '[:lower:]' hello world! -
Use awk:
[tum@ezylinux ~]$ echo 'Hello World!' | awk '{print tolower($0)}' hello world! -
In Bash 4.0 or later, use the following:
[tum@ezylinux ~]$ A='Hello World!' [tum@ezylinux ~]$ echo ${A,,} hello world! -
Use Perl:
[tum@ezylinux ~]$ echo 'Hello World!' | perl -ne 'print lc' hello world!