Upper and lower casing | skybert.net

Upper and lower casing


Many people use external commands such as tr and awk for uppercasing and lowercasing strings, but this is not necessary. BASH 4 and later can do this all by itself.

To upper case

jira_key=foo-2343
printf "%s\n" ${jira_key^^}

Result:

FOO-2343

To lower case

jira_key=FOO-2343
printf "%s\n" ${jira_key,,}

Result:

foo-2343

Licensed under CC BY Creative Commons License ~ gmail torstein.k.johansen @ gmail ~ twitter @torsteinkrause ~