Results 1 to 5 of 5
Hello,
I need one command for my script how print in one file all the word how match more that "nr" time in an gived named file.
Thanks for help...
- 03-10-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 1
awk, sed or grep?
Hello,
I need one command for my script how print in one file all the word how match more that "nr" time in an gived named file.
Thanks for help
- 03-10-2010 #2
I would use Gawk/awk myself but I'm more comfortable with Gawk/awk...
Make mine Arch Linux
- 03-11-2010 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
Not sure exactly what you want, but this should be a good start. It essentially comes from Chapter 4 of _The Unix Programming Environment_ by Kernighan and Pike, 1984.
< inputfile tr -sc [:alpha:] '\n' | sort | uniq -c | sort -nr | head -10
Explanation:
tr -sc converts all non-alphabetic characters to newlines, and compresses adjacent newlines to one. Thus giving a list of words, one per line.
sort puts identical words together
uniq -c gives a count of identical words, with an example of each
sort -nr numerically sorts the count, in reverse order
head -10 selects the 10 words of greatest frequency.
Example, running this script on a manual page text output, I get:
man man | col -b | tr -sc [:alpha:] '\n' | sort | uniq -c | sort -nr | head -10
117 the
80 man
52 is
52 a
45 to
36 of
30 page
27 in
27 for
24 pages
- 03-11-2010 #4Just Joined!
- Join Date
- Mar 2008
- Posts
- 1
This not an aswer to your question but a general comment.
Shorter your question, shorter and more cryptic the answer you get.
If you give your full requirement and the context, it helps a lot when someone is willing and ready to answer your question.
When you ask a question that is vague, you get vague answers as people here, though very qualified and capable of answering your Q have to guess what you are trying to do and come with their own solution which may or may not satisfy your need.
- 03-12-2010 #5Just Joined!
- Join Date
- Dec 2006
- Posts
- 4
Could you explain, in more detail, what you want to do?


Reply With Quote

