Question
Write a shell script that implements a simple spell checker. in UNIX Linux The name of your script is formed from your Z-id followed by
Write a shell script that implements a simple spell checker. in UNIX Linux 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 clockwise to 360 in ECMD compass convention (0 being north, 90 being east). Course is customarily expressed in three digits, using preliminary zeros if needed. % ./z123456.spell testfile 'agle' is mispelled. Press "Enter" to keep this spelling, or type a correction here: angle 'objekt' is mispelled. Press "Enter" to keep this spelling, or type a correction here: object 'truenorth' is mispelled. Press "Enter" to keep this spelling, or type a correction here: 'ECMD' is mispelled. Press "Enter" to keep this spelling, or type a correction here: MISPELLED: CORRECTIONS: agle angle objekt object % ./z123456.spell testfile 'agle' is mispelled. Press "Enter" to keep this spelling, or type a correction here: angle 'objekt' is mispelled. Press "Enter" to keep this spelling, or type a correction here: object MISPELLED: CORRECTIONS: agle angle objekt object % cat ~/.memory truenorth ECMD % 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 clockwise to 360 in ECMD compass convention (0 being north, 90 being east). Course is customarily expressed in three digits, using preliminary zeros if needed.
Additional Notes:
- Your file must mention /bin/bash in its shebang line.
- Make sure your script does not leave any temporary files behind.
- Make sure that your script file is a regular Unix text file. Don't add an extension (such as .txt) to the file name. Don't modify your file on Windows using notepad, it will add extra ^M characters at the end of each line.
Submit your script file by attaching it to the submission dialog below.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started