![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need to replace the first word of a line if it occurs again in the next line(shell) | geeko | Shell Programming and Scripting | 4 | 06-18-2009 02:36 PM |
| ls - maximum number of files | karnan | UNIX for Dummies Questions & Answers | 6 | 10-15-2008 05:56 PM |
| maximum number of arguments | matrixmadhan | UNIX for Dummies Questions & Answers | 9 | 10-15-2008 05:03 PM |
| maximum number of times - a file can be opened | matrixmadhan | High Level Programming | 3 | 03-21-2006 11:24 AM |
| Number of login times | ftengcheng | AIX | 7 | 08-02-2005 03:35 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
TO find the word which occurs maximum number of times
Hi Folks !!!!!!!!!!!!!!!!!!!
My Requirement is............. i have a input file: 501,501.chan 502,502.anand 503,503.biji 504,504.raja 505,505.chan 506,506.anand 507,507.chan and my o/p should be chan->3 i.e. the word which occurs maximum number of times in a file should be displayed.. Its Really Urgent!!!!!!!!!!!!!!!!!!! |
|
||||
|
awk solution
Hi,
I am not sure whether this one is more efficient for you. Please try on your file, any result let all of us here know. Code:
awk 'BEGIN{FS="."}
{
sum[$2]++
}
END{
for (i in sum)
print i"->"sum[i]
}' file > file.t
sort -t">" +1 -n file.t | tail -1
rm file.t
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|