How to Convert a String to Lower Case in Bash

Is there a way in to convert a string into a lower case string?

For example, if I have:

a="Hi all"

I want to convert it to:

"hi all"
1

26 Answers

The are various ways:

POSIX standard

tr

$ echo "$a" | tr '[:upper:]' '[:lower:]'
hi all

AWK

$ echo "$a" | awk '{print tolower($0)}'
hi all
Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.