Bash uppercase string


This post goes over how to uppercase a string in bash with:

awk

To uppercase a string with awk:

echo 'string' | awk '{ print toupper($0) }'

To lowercase the string, replace toupper with tolower:

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

tr

To uppercase a string with tr:

echo 'string' | tr '[:lower:]' '[:upper:]'

To lowercase the string, flip the order of '[:lower:]' '[:upper:]':

echo 'string' | tr '[:upper:]' '[:lower:]'


Please support this site and join our Discord!