#!/bin/bash # filename: spell-check.sh # Pete Nesbitt, Jan 2016 # quick script to check spelling on a single word # requires "aspell" package, available with most distributions. # aspell uses *, &, and # for result status: # # * = OK "*" (nothing else on line) # & = Suggestions: "& kyak 15 0: kayak, yak,..." # # = None: "# kjlsdkfaioj 0" clear echo echo # Get search term from user ($WORD) printf " => Enter a Word to Spell Check: " read WORD echo # run aspell A_RESULTS="`echo "${WORD}" | aspell -a --ignore-case | egrep -v "^$|^\@\(\#\)"`" # check status, if * & or # STAT_CHAR="`echo "${A_RESULTS}" | cut -c1`" if [ "${STAT_CHAR}" = "&" ];then # list of words echo "Suggestions for ${WORD}:" echo "${A_RESULTS}" | cut -d: -f2 | sed 's/^\ //' | fold -s | sed 's/^/\ \ \ /' elif [ "${STAT_CHAR}" = "*" ];then # no errors echo "${WORD} is spelled correctly" elif [ "${STAT_CHAR}" = "#" ];then # no suggestions echo "Sorry, no suggestions for:" echo " ${WORD}" else echo "error" exit 1 fi echo echo exit 0 # eof