s="Hello World"
echo "${s^^}" # HELLO WORLD — uppercase all
echo "${s,,}" # hello world — lowercase all
echo "${s^}" # Hello World — uppercase first char
echo "${s,}" # hello World — lowercase first char
# Title-case each word using awk (no built-in for this)
title() { echo "$*" | awk '{for (i=1; i<=NF; i++) $i = toupper(substr($i,1,1)) tolower(substr($i,2))} 1'; }
title "the lord of the rings" # The Lord Of The Rings
Create a free account and build your private vault. Share publicly whenever you want.