Todd Slater wrote:

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.


[snip]

Well, this sounds like a good job for perl...

perl -e 'open F,$ARGV[0];for(<F>){for(split /\W/,$_){$t{lc $_}++}}for(sort keys %t){print $_, " => ", $t{$_}, "\n"}' forums.txt

Will count all the occurrences of words, w/o non-word chars, lower the case and print them in order.

HTH

-- mike higgins

____________________________________________________
Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com
Join the Club : http://www.mandrakeclub.com
____________________________________________________

Reply via email to