Created
December 20, 2021 14:53
-
-
Save hexaflexahexagon/78f73017e8fd1f34fb78f667c5c02b8b to your computer and use it in GitHub Desktop.
# given a phrase, convert into an acronym
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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