LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 05-19-2003, 02:44 AM   #1
x2000koh
Member
 
Registered: Jul 2002
Location: singapore
Distribution: red had 7.2
Posts: 109

Rep: Reputation: 15
top 10 highest frequency


Hi ! Linux Expert
I have created a file(DOMAIN LIST) which contains all the domain names.

The file contain is as follow:

www.yahoo.com
www.hotmail.com
www.lycos.com
www.ibm.com
www.yahoo.com
www.ibm.com
www.lycos.com
www.yahoo.com
........
....
...

QUESTION
I have more than hundred of entry in the above file. What command can I use to show "the highest frequency" of the contain. I mean I want to list down the top ten list.

Your assistant is highly appreciated.

X2000koh
 
Old 05-19-2003, 03:41 AM   #2
Manish
Member
 
Registered: Feb 2002
Distribution: Debian / Debian-based
Posts: 58

Rep: Reputation: 15
a combination of 3 utilities (sort, uniq, head) can help you. Look up man pages on these.
 
Old 05-19-2003, 06:13 AM   #3
acjt
Member
 
Registered: Dec 2002
Location: Australia
Distribution: Gentoo
Posts: 161

Rep: Reputation: 30
Quote:
Don't bash Windows or Linux unless you DO have a clue.
Don't dare to compare C++ , Java or C unless you DO have a clue .
I like your signature.
Define clue though!
 
Old 05-19-2003, 08:27 AM   #4
x2000koh
Member
 
Registered: Jul 2002
Location: singapore
Distribution: red had 7.2
Posts: 109

Original Poster
Rep: Reputation: 15
how to do it

manish,
I have used the sort, uniq and head. But how to calculate the high frequency and list the domain of the top ten higher list

Appreciate your help

x2000koh
 
Old 05-19-2003, 09:37 AM   #5
Manish
Member
 
Registered: Feb 2002
Distribution: Debian / Debian-based
Posts: 58

Rep: Reputation: 15
ok. Take a look at the following bash script. You may have to modify it to suit your requirements, and it doesn't use pipes,etc (hence requires temporary files to be created).

Code:
#! /bin/bash
if ((test -z $1) || !(test -e $1))
then
    exit
fi
sort $1 > /tmp/top10.tmp
uniq -c /tmp/top10.tmp > /tmp/top10.tmp2
sort -r /tmp/top10.tmp2 > /tmp/top10.tmp
# remove the "| cut -f 2" part to display frequency numbers
head -10 /tmp/top10.tmp | cut -f 2

Last edited by Manish; 05-19-2003 at 09:41 AM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Distros: Highest number of packages ? Youssef_C Linux - Distributions 5 11-02-2005 06:32 PM
Highest Paid Stream In Computers emailssent General 16 06-26-2005 09:06 PM
sql: highest value, comparing fields Ephracis Programming 6 06-01-2005 05:28 PM
Setting the highest display resolution artemis Fedora 3 06-16-2004 02:32 AM
kde.org highest rated KDE theme BajaNick General 5 04-10-2004 04:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:20 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration