#! /bin/bash # # Filename: spellcheck # # From Mark Sobell's Red Hat Linux book. Adapted by Br. David Carlson. # # Date: March 26, 2007 # # This script lists possible misspellings in the file given as the first parameter. # The optional second parameter is a file of correctly spelled words that are not # in the dictionary. That is, they are an extension of the dictionary. if [ $# -eq 1 ] then if [ -r "$1" ] then aspell -l < "$1" else echo "$1 is not a readable file" 1>&2 exit 1 fi elif [ $# -eq 2 ] then if [ ! -r "$1" ] then echo "$1 is not a readable file" 1>&2 exit 2 elif [ ! -r "$2" ] then echo "$2 is not a readable file" 1>&2 exit 3 else temp="/tmp/spellcheck.$$" aspell -l < "$1" > "$temp" while read line do result=`grep "$line" "$2"` if [ "junk$result" = "junk" ] # The $line word is not in the $2 dictionary extension. then echo "$line" fi done < "$temp" fi else # number of parameters is 0 or is greater than 2 echo "Syntax: spellcheck [file_of_additional_spellings]" 1>&2 exit 4 fi exit 0