>> On Thu, 30 Dec 2010 10:34:59 -0800 (PST), >> S Mathias <smathias1...@yahoo.com> said:
S> ...recursively count the words occurrence in the text files. This assumes words consist of alphanumeric characters only. If that's not the case, you'll need to change the "tr/" line in the script. me% head */* ==> one/asf.txt <== word1 word2 word3 ==> one/asfcxv.txt <== word2 word4, word5 ==> one/dsgsdg.txt <== word1. word2 ==> three/qwerbdsg.txt <== word7, word8 word9 word10 ==> three/weberg.txt <== word4 word3 ==> three/werdf.txt <== asdf, word2 ==> two/ergd.txt <== word6 ==> two/sdgsddsf.txt <== word6, word3 me% cat words #!/usr/bin/perl -w use strict; my %words; while (<>) { tr/a-zA-Z0-9/ /cs; foreach my $w (split) { $words{$w}++; } } foreach (sort keys %words) { print "$_ $words{$_}\n"; } exit(0); me% ./words */* asdf 1 word1 2 word10 1 word2 4 word3 3 word4 2 word5 1 word6 2 word7 1 word8 1 word9 1 -- Karl Vogel I don't speak for the USAF or my company Never take a beer to a job interview. --Martha Stewart's tips for Rednecks -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20101230213326.cc245b...@kev.msw.wpafb.af.mil