#!/bin/bash
# remove correct spellings from ispell output

if [ $# -ne 2 ]
	then
		echo "Usage: spell_check file1 file2" 1>&2
		echo "file1: list of correct spellings" 1>&2
		echo "file2: file to be checked" 1>&2
		exit 1
fi

if [ ! -r "$1" ]
	then
		echo "spell_check: $1 is not readable" 1>&2
		exit 1
fi

if [ ! -r "$2" ]
	then
		echo "spell_check: $2 is not readable" 1>&2
		exit 1
fi

ispell -l < "$2" |
while read line
do
	if grep -v "^$line$" "$1" > /dev/null
		then
			echo $line
	fi
done
