|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi guys,
i need to search the most commonly occuring words in a file and display their counts of about 30000 words and the words shud not be of typ specified in file 2 e. words like is,for,the,an,he,she etc... k. file1: ALICE was beginning to get very tired of sitting by her sister on the bank and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is the use of a book," thought Alice, "without pictures or conversations?' So she was considering, in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her. file2: was to get of by her on the etc.... output: ALICE : 1 begining : 1 etc... Cud u help me with this ![]() |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
This looks suspiciously like homework.
|
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
This is actually quite a famous problem. I quote verbatim from "Classic Shell Scripting" Quote:
Code:
#! /bin/sh
# Read a text stream on standard input, and output a list of
# the n (default: 25) most frequently occurring words and
# their frequency counts, in order of descending counts, on
# standard output.
#
# Usage:
# wf [n]
tr -cs A-Za-z\' '\n' |
# Replace nonletters with newlines
tr A-Z a-z |
#Map uppercase to lowercase
sort |
#Sort the words in ascending order
uniq -c |
#Eliminate duplicates, showing their counts
sort -k1,1nr -k2 |
#Sort by descending count, and then by ascending word
sed ${1:-25}q
#Print only the first n (default: 25) linesIt's not exactly what you need, but you now have a strong model to work from. Enjoy |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| displaying $ in data | ammu | UNIX for Dummies Questions & Answers | 2 | 02-19-2008 02:00 PM |
| displaying the users | needyourhelp | UNIX for Dummies Questions & Answers | 1 | 09-13-2007 01:37 AM |
| displaying with ls | vivekshankar | UNIX for Dummies Questions & Answers | 2 | 05-23-2005 03:46 PM |
| Displaying what a command is doing/has done | quantumechanix | UNIX for Dummies Questions & Answers | 1 | 07-02-2003 08:40 AM |
| displaying date | minazk | Shell Programming and Scripting | 7 | 11-14-2002 11:04 AM |
|
|