[Code Example] String to lowercase using bash script


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

Demo might not work in private window (incognito)

Sign Up for Our Newsletters

Get only the best articles delivered to your mail

You May Also Like