Wicked Cool Shell Scripts
Wicked Cool Shell Scripts :: shell script 027-spelldict.sh

Shell Script 027-spelldict.sh

#!/bin/sh

# spelldict - use the 'aspell' feature and some filtering to allow easy
#    command-line spell checking of a given input (file)

okaywords="$HOME/.okaywords"
tempout="/tmp/spell.tmp.$$"
spell="virtual aspell"                  # tweak as needed

trap "/bin/rm -f $tempout" EXIT
 
if [ -z "$1" ] ; then
  echo "Usage: spell file|URL" >&2; exit 1
elif [ ! -f $okaywords ] ; then
  echo "No personal dictionary found. Create one and rerun this command" >&2
  echo "Your dictionary file: $okaywords" >&2
  exit 1
fi

for filename
do
  $spell -a < $filename | \
  grep -v '@(#)' | sed "s/\'//g" | \
     awk '{ if (length($0) > 15 && length($2) > 2) print $2 }' | \
   grep -vif $okaywords | \
   grep '[[:lower:]]' | grep -v '[[:digit:]]' | sort -u | \
   sed 's/^/   /' > $tempout
 
   if [ -s $tempout ] ; then
     sed "s/^/${filename}: /" $tempout
   fi
done

exit 0

Explore The Book!
[book cover]
Table of Contents
Read Some Scripts!
Shell Script Library
Book Errata
All The Links
Read the Reviews
Talk About It
Author Bio
Buy The Book!



Other books by author Dave Taylor
Learning Unix for Mac OS X (O'Reilly & Associates)
Solaris 9 for Dummies (Wiley)
Teach Yourself Unix in 24 Hours (Sams/Macmillan)
Teach Yourself Unix System Administration in 24 Hours (Sams/Macmillan)
Creating Cool HTML 4 Web Pages (Wiley)
Ten Quick Steps to Learning Mac OS X Unix (ebook!)