problem with exec
Andrew
mathas_a at maths.su.oz.au
Tue Jul 10 22:00:34 AEST 1990
Any ideas anyone?
Andrew
______________________________________________________________
#!/bin/ksh
# counts the number of unique words in a file
# - unless the -t option is used assumes a TeX input file
# - ignores words of length 1
if [ $# = 0 ]
then
echo "Usage: words [-text] file"
else
case $1 in
-t*)
cmd="tr -cs A-Za-z '\012' < $2"
;;
*)
cmd="prespell < $1.tex | tr -cs A-Za-z '\012'"
;;
esac
exec $cmd | sort |
awk '
{
if ( length($1) > 1)
{
word+=1
repword+=1
lastword = $1
while ( getline && $1 == lastword )
repword+=1
}
}
END \
{
per = int(100*word/repword)
printf " %d words %d unique (%d%)\n", repword, word, per
}'
fi
_______________________________________________________________
--
- smile at a stranger today and help make the world a better
place; while you're, at it, why not hug a friend!
More information about the Comp.unix.questions
mailing list