home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!sdd.hp.com!usc!rpi!fitzgb
- From: fitzgb@mml0.meche.rpi.edu (Brian Fitzgerald)
- Newsgroups: comp.unix.programmer
- Subject: Re: text file word counter ?
- Message-ID: <!lfy8n#@rpi.edu>
- Date: 18 Aug 92 21:35:49 GMT
- References: <1992Aug18.102143.1@vax.sonoma.edu>
- Organization: Rensselaer Polytechnic Institute, Troy, NY
- Lines: 23
- Nntp-Posting-Host: mml0.meche.rpi.edu
-
- mccalld@vax.sonoma.edu writes:
- >Greetings:
- > Looking for a programming package which counts the number of unique
- >words in a file and displays the results, and also counts the number of
-
- deroff -w [file] | sort | uniq -d | wc -w (Yuck!)
-
- or
-
- deroff -w [file] | tr A-Z a-z | sort | uniq -d | wc -w
-
- >times each unique word appears within the file.......
-
- deroff -w [file] | awk '{w[$1]++};END{for (i in w){print i, w[i]}}' ...
-
- (based on Aho, Kernighan, and Weinberger, "The AWK Programming
- Language", Addison Wesley, 1988)
-
- where ... can be "| sort", "| sort -n +1", "| sort -f", etc...
-
- If [file] is omitted, the pipeline reads from the standard input.
-
- Brian
-