The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to filter the words, if that word contains the expected letter venu_eie UNIX for Advanced & Expert Users 3 03-19-2008 09:00 AM
how i display number in words amitpansuria High Level Programming 3 08-26-2007 05:02 AM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 03:29 AM
return a word between two words bryan UNIX for Dummies Questions & Answers 4 05-23-2006 10:56 AM
How to replace a word with a series of words in a file brap45 Shell Programming and Scripting 2 02-20-2006 10:33 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-23-2008
Registered User
 

Join Date: May 2008
Location: India
Posts: 6
Display most top 10 occurring words along with number of ocurences of word inthe text

I need Display the most top 10 occurring words along with the number of occurences of those words in the given text.

Sample text as below:


"The Travails of Single South Indian men of conservative upbringing" or "Why we don't get any..."
Yet another action packed weekend in Mumbai, full of fun, frolic and introspection. I have learnt many things. For example having money when none of your friends have any is as good as not having any. And after spending much time in movie theatres, cafes and restaurants I have gathered many insights into the endless monotony that is the love life of south Indian men. What I have unearthed is most disheartening.
Disheartening because comprehension of these truths will not change our status anytime soon. However there is also cause for joy. We never stood a chance anyway. What loads the dice against virile, gallant, well educated, good looking, sincere mallus and tams? ( Kandus were once among us, but Bangalore has changed all that.)
Our futures are shot to hell as soon as our parents bestow upon us names that are anything but alluring. I cannot imagine a more foolproof way of making sure the child remains single till classified advertisements or that maternal uncle in San Francisco thinks otherwise. Name him " Parthasarathy Venkatachalapthy" and his inherent capability to combat celibacy is obliterated before he could even talk.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-23-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,667
You can try something like:

Code:
tr " " "\n" < file|sort|uniq -c|sort -r|head -10
Regards
Reply With Quote
  #3 (permalink)  
Old 05-23-2008
Registered User
 

Join Date: May 2008
Location: India
Posts: 6
Thanks.It is working fine.

Output:

7 of
5 is
4 the
4 have
4 as
4 and
4 I
3 that
3 in
2 to
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0