Skip to content

Instantly share code, notes, and snippets.

@nexus166
Last active July 28, 2020 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nexus166/b335b79e24b0e9055efa63729b015628 to your computer and use it in GitHub Desktop.
Save nexus166/b335b79e24b0e9055efa63729b015628 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
declare -A CHART=(
["a"]="alpha" ["b"]="bravo" ["c"]="charlie"
["d"]="delta" ["e"]="echo" ["f"]="foxtrot"
["g"]="golf" ["h"]="hotel" ["i"]="india"
["j"]="juliet" ["k"]="kilo" ["l"]="lima"
["m"]="mike" ["n"]="november" ["o"]="oscar"
["p"]="papa" ["q"]="quebec" ["r"]="romeo"
["s"]="sierra" ["t"]="tango" ["u"]="uniform"
["v"]="victor" ["w"]="whiskey" ["x"]="x-ray"
["y"]="yankee" ["z"]="zulu"
)
for _c in "${!CHART[@]}"; do
CHART["${_c^^}"]="${CHART[${_c}]^^}"
done
CHART+=(
["1"]="ONE" ["2"]="TWO" ["3"]="THREE"
["4"]="FOUR" ["5"]="FIVE" ["6"]="SIX"
["7"]="SEVEN" ["8"]="EIGHT" ["9"]="NINE"
["0"]="ZERO" ["!"]="exclamation" ["?"]="questionmark"
["#"]="hash" ["&"]="ampersand" ["+"]="plus"
["-"]="dash" ["|"]="pipe" ["$"]="dollar"
["%"]="percent" ["_"]="underscore" ["/"]="slash"
['\']="backslash" ["*"]="asterisk" ["@"]="at"
["="]="equals" ["("]="left parenthesis" [")"]="right parenthesis"
["["]="square bracket open" ["]"]="square bracket closed" ["{"]="brace open"
["}"]="brace closed" ["."]="dot" [","]="comma"
[";"]="semicolon" [":"]="colon"
)
INPUT="${*}"
for ((i = 0; i < ${#INPUT}; i++)); do
_c="${INPUT:i:1}"
case "${_c}" in
" ") printf '\t' ;;
*) printf '[%s]%s ' "${_c}" "${CHART["${_c}"]}" ;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment