Find the answer to your Linux question:
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...
  1. #1
    Just 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

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    I would use Gawk/awk myself but I'm more comfortable with Gawk/awk...
    Make mine Arch Linux

  3. #3
    Just Joined!
    Join Date
    Jul 2008
    Posts
    81
    Quote Originally Posted by thewalker View Post
    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
    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

  4. #4
    Just 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.

  5. #5
    Just Joined!
    Join Date
    Dec 2006
    Posts
    4
    Could you explain, in more detail, what you want to do?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...