LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 05-10-2007, 03:20 AM   #1
mystical dervish
LQ Newbie
 
Registered: May 2007
Posts: 25

Rep: Reputation: 15
counting words in file and sorting them according to their frequency


Hello
I have a text file , I want to count every word how many times it's repeated in this file then put the results in outpout file like

Going 9
right 8
yes 7
now 6
.....
hello 2

ignoring the case of letters (YeS=yes)
I need your help to write a script achieve that

thanx
 
Old 05-10-2007, 03:38 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

Rep: Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945
this sounds so so much like homework, which we are not here to help you with. if it is, please understand it is for you to learn, not for us to spoon feed you. if not, please provide more context behind this rquest and we can look at giving some hints and tips...
 
Old 05-10-2007, 03:55 AM   #3
mystical dervish
LQ Newbie
 
Registered: May 2007
Posts: 25

Original Poster
Rep: Reputation: 15
Never , I'm not doing a homework
in fact I'm doing big research using Linux OS which I'm still beginner with, may be it seems as a stupid question but I really don't in a homework , just a beginner

thanx even if I don't get a help
 
Old 05-10-2007, 04:05 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

Rep: Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945
cat file.txt | tr ' ' '\n' | sort | uniq -ic | sort

Last edited by acid_kewpie; 05-10-2007 at 04:12 AM.
 
Old 05-10-2007, 08:58 AM   #5
mystical dervish
LQ Newbie
 
Registered: May 2007
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by acid_kewpie
cat file.txt | tr ' ' '\n' | sort | uniq -ic | sort
thank you it works well
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ "counting words in a string" Rico16135 Programming 11 05-06-2009 12:30 PM
Counting occurances in file stefaandk Linux - General 1 08-13-2005 08:55 AM
Sorting a file containing dates subu_s Linux - General 2 06-03-2004 01:07 PM
Sorting a list of words in LISP! Hady Programming 1 05-01-2004 03:29 PM
File sorting problem Kerridis Linux - General 3 03-08-2004 10:44 PM


All times are GMT -5. The time now is 12:24 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration