by @CodingExample

How to convert a string into a lowercase in Bash

Home » bash » How to convert a string into a lowercase in Bash

We can use POSIX standard tr '[:upper:]' '[:lower:]' command to convert a string into a lowercase in bash.

Here is an example that converts the string WE LOVE CODING to lowercase.

p="WE LOVE CODING"

echo "$p" | tr '[:upper:]' '[:lower:]'

Output:

we love coding

Similarly, you can also do it like this.

p="WE LOVE CODING"

echo "$p" | awk '{print tolower($0)}'