The problem I'm having is that I want to read in whether the user wants to keep the spelling or change it, but the "read spelling" pulls from the 'line' and not from user input.
my assignment description is as follows.
Write a shell script that implements an interactive spell checker. The general format for invocation is:
wordspell file
where "wordspell" is the name of the executable file that contains your shell script, and "file" refers to the file to be checked word-by-word for spelling.
Your are encouraged to take advantage of the "ispell -l" command. It produces a list of misspelled words from standard input.
Specification:
wordspell reads "file" and checks it for spelling of the words it contains. wordspell is invoked interactively. For each word that is found to be incorrect, the invoker is asked for either:
* to insist on the spelling of the word.
* to provide a replacement spelling
If the invoker insists on the spelling of the word, then this word is added to wordspell's "memory". wordspell remembers words in the file "memory" in the invoker's home directory. Any further invocation of wordspell by the same invoker will consider the word to be correct.
Otherwise the invoker is prompted for a replacement spelling. As output, wordspell produces a 2-column-ed list of words, the left column lists incorrectly spelled words, the right column lists their replacement as given by the invoker. The list is produced after the invoker has answered to all incorrectly spelled words.
#! /bin/bash
touch memory
touch tempword
ispell -l < "$1" |
while read line
do
echo "$line is mispelled. Press "'Enter'" to keep this spelling, or type a correction here:"
read spelling
if [$spelling = ""]; then
echo $line >> memory
else
echo $spelling >> tempword
fi
done
paste memory tempword > allfile
#echo $allfile
Any help would be appreciated. thanks!