#!/usr/bin/env bash # replaces any character that is not alphanumeric ([:alnum:]), # a blank space ([:blank:]), or a single quote (') with a space character # and convert to uppercase phrase=$(echo "$1" | tr -c "[:alnum:][:blank:]'" " " | tr "[:lower:]" "[:upper:]") # appends the first character of each word to $acronym for word in $phrase; do acronym+=$(echo "${word:0:1}") done echo "$acronym"