脚本代码:
#!/bin/bash #directory.sh #check the word spelling errors in the given text E_BADARGS=65 [ $# -lt 2 ]&&echo "Usage:./directory filename1 filename2."&&exit \ $E_BADARGS
echo "###################Mcknight##############################" path="/usr/share/dict/linux.words" #modify the text file to suit the search cat $1|tr A-Z a-z|sed 's/[,!?.]/ /g'|sed 's/ */ /g' >$2
for word in $(cat $2);do if [ "$word" == "i" ];then continue fi #donnot want "i" to bother! grep -q "\<$word\>" $path if [ "$?" -eq 0 ];then continue else echo -e "\033[0;31m$word \033[1;37mspells wrongly!" fi done echo "###################Check done!###########################" |