On Thu, Aug 19, 2004 at 11:29:22AM +0100, Paul Smith wrote: > Dear All > > Does somebody know about a program for giving us the number of > occurrences of each word in a text file? > > Thanks in advance, > > Paul
I don't know of a program that does it--perhaps it's built in to a word processor? You can use a few commands to accomplish the same thing. 1. Get words on a line of their own, and get rid of punctuation, and get everything the same case. tr ' \011' '\012\012' <originalfile |tr -d [:punct:]|tr [A-Z] [a-z]|sort > masterwordlist (that should all be one line) 2. Get unique words to count from masterwordlist. uniq masterwordlist > uniqwords 3. Count the number of times a word in uniqwords appears in masterwordlist. for line in `cat uniqwords` ; do echo $line : `grep -c $line masterwordlist` >> countedwords ; done (that should all be one line) There's probably more n better ways to do it, but that should work. Modify to suit your needs, like if you want to distinguish between A and a. Todd
____________________________________________________ Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com ____________________________________________________