String to lowercase using bash script – Code Example


In this article I will provide you the bash script code to convert your strings to all lowercase. We require this functionality a lot like when storing usernames, emails, url slugs etc. Case sensitive data can create errors and that’s why we keep some data in lowercase only.

Code Example –


lower() {
    echo "${1,,}"

lower "AN animAl is aN animal. DONKEY or DOG does NoT mAtTeR"

# Output:
# an animal is an animal. donkey or dog does not matter

Inspired from Dylan Araps

Live Demo

Open Live Demo