Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!metro!news From: mathas_a@maths.su.oz.au ( Andrew ) Newsgroups: comp.unix.questions Subject: problem with exec Message-ID: <1990Jul10.120034.10119@metro.ucc.su.OZ.AU> Date: 10 Jul 90 12:00:34 GMT Sender: news@metro.ucc.su.OZ.AU (news) Reply-To: mathas_a@maths.su.oz.au ( Andrew ) Organization: Mathematics, University of Sydney exec $cmd | ... exec tr -cs A-Za-z '\012' < $2" | ... Lines: 51 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!