Question: UNIX / C: modify Code: Modify the mySpell script so that if you fail to enter the file name, it will print a reminder, e.g.,
UNIX / C: modify Code:
Modify the mySpell script so that if you fail to enter the file name, it will print a reminder, e.g., Usage: mySpell filename.
HERE is the Code:
% more mySpell #!/bin/sh # An improved spelling checker file=$1 for word in spell $file do # grep tries to find the line where $word occurs in $file line=grep -n $word $file #print out a line echo " " #print out the following line echo "Missplled word: $word" #print out the line where the misspelled word occurs echo "$line" done
2.) Modify the delFile script so that it will test if the one to be deleted is a directory, in this case, it should call rmdir instead of rm to delete it. Notice that the following line tests if dirname is a directory, which sends back True if the value of $dirname holds a directorys name. if test ! -d $dirname
Here code:
% more delFile #!/bin/sh #Delete a file interactively filename=$1 if test ! -f $filename then echo "There is no file \"$filename\"." else echo "Do you want to delete \"$filename\"?" read choice if test $choice = y then rm $filename echo \"$filename\" deleted else echo \"$filename\" not deleted. fi fi
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
