Unique Word Counter Needed
Steve Schlaifer x3171 156/224
steve at jplgodo.UUCP
Sat Dec 14 06:15:08 AEST 1985
>
> I need a way to count unique words in a document.
> Does any one have suggestions on a simple way to do this?
> gpw
>
> --
a simple (Bourne) shell script on system V is:
awk '{ for(i=1; i<=NF; ++i) print $i }' file | sort | uniq -c
prints a sorted list of the words in *file* preceded by a count of the number
of times each word appeared in the file. I expect this will work on other
systems but don't have enough experience to really know. To just count the
number of distinct words in file change uniq -c to uniq | wc -l
To list words that only occur once, add
| awk '$1==1 { print $2 }'
to the end of the pipe. There are many other variations on this that will
occur to you as you play with it.
Enjoy, Steve Schlaifer ( {group3 | smeagol}!jplgodot!steve )
More information about the Comp.unix
mailing list