Skip to content

Instantly share code, notes, and snippets.

@hexaflexahexagon
Created December 20, 2021 14:53
Show Gist options
  • Save hexaflexahexagon/78f73017e8fd1f34fb78f667c5c02b8b to your computer and use it in GitHub Desktop.
Save hexaflexahexagon/78f73017e8fd1f34fb78f667c5c02b8b to your computer and use it in GitHub Desktop.
# given a phrase, convert into an acronym
#!/bin/bash
# given a phrase, convert into an acronym
# Portable Network Graphics -> PNG
# this assumes only that the words are separated by spaces, case doesn't matter
if [ -z "$1" ]; then
echo "Error: Please enter a quoted phrase to acronymize"
exit -1
fi
acronym=$(echo "$1" | awk -F=' ' '{
split($0, words, " ")
for (i in words) {
split(words[i], chars, "")
output = output chars[1]
}
print toupper(output)
}')
echo "\"$1\" as an acronym is \"$acronym\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment