Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save packetpilot/e26eee3013446dc4db1ad7f83ae492d5 to your computer and use it in GitHub Desktop.
Save packetpilot/e26eee3013446dc4db1ad7f83ae492d5 to your computer and use it in GitHub Desktop.
[bash] Convert an ALL CAPS list (or csv etc) to Just First Letter Capitalized
bash-4.4$ cat CAPSTITLES
SR IMPORTANT PERSON
JR SOMETHING OTHERTHING
DIR JANITORIAL
HEAD OF ALL NECKS
PLEB
SEÑOR DIVERSITY ADVOCATE
SR. PERIOD TESTER
LEAD, PUNCTUATION TESTERS
WOULD,THIS,WORK,ON,A,CSV?
# this is a one-liner that's been split for readability.
bash-4.4$ while IFS='' read TITLE || [[ -n "${TITLE}" ]]; \
do echo "${TITLE,,}"; done < CAPSTITLES \
| sed -e "s/\b\(.\)/\u\1/g" > LessShoutyTitles
bash-4.4$ cat LessShoutyTitles
Sr Important Person
Jr Something Otherthing
Dir Janitorial
Head Of All Necks
Pleb
Señor Diversity Advocate
Sr. Period Tester
Lead, Punctuation Testers
Would,This,Work,On,A,Csv?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment