Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a shell script that implements a simple spell checker. The name of your sc

ID: 3529175 • Letter: W

Question

Write a shell script that implements a simple spell checker. The name of your script is formed from your Z-id followed by ".spell". For example, if your Z-id is "z123456" then your script must be called "z123456.spell". The general format for invocation is: z123456.spell file where "z123456.spell" 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 "aspell list" command. It produces a list of misspelled words from standard input. Specification: When your script is invoked from the command line it reads "file" and checks it for spelling of the words it contains. 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 your script will "remember" it. Your script "remembers" words in the file "~/.memory" in the invoker's home directory. Any further invocation of your script by the same invoker will consider the word to be correct. Otherwise, the invoker is prompted for a replacement spelling. As output, your script 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. Here is an example of an invocation of your script with a testfile: % ls testfile z123456.spell % cat testfile In navigation, a vehicle's course is the agle that the intended path of the vehicle makes with a fixed reference objekt (typically truenorth). Course is measured in degrees from 0

Explanation / Answer

Please rate with 5 stars: "${replace}" instead of "$replace" (but that's a style preference, designed to prevent variables from being subbed incorrectly) So, while [$word != ""] should be while [ "${word}" != "" ] or at least [ "$word" != "" ] or else /bin/test is going to puke whenever $word is empty. Problem 2: The expected behavior, if the user types in "someword" to replace "someword", is to treat that as in insistence. So the second test should be if [ "${replace}" == "${word}" -o "${replace}" == "" ] Problem 3: Having two "read words" is going to make debugging hard. I would change the loop to look like this: word="a" while [ "${word}" != "" ] do read word

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote