Bash

Uppercase / Lowercase / Title Case

admin by @admin ADMIN
Jun 17, 2026
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
Bash 4+ has built-in case conversion via parameter expansion. No need for `tr` or `awk` for most cases.
Bash
Raw
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
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.