awk - Check which string in certain column is repeated -


I have to see that the string has to be repeated in my column 2.

For example: An apple b peach C grapes D peach e peach F. apple

My output will be:

  An apple f apple peach d peach e peach   

Showing the entire line on the second row with the normal string.

If you do not want to store all the files in memory, the best part is that the file Have to read twice

  $ awk 'FNR == NR {a [$ 2] ++;              
  • To print the other lines, in which the second column is counted at least twice.

    As you reproduce the exact output you received, just pipe it on sort indicates that it was first column 2 and then column Sort by 1:

      awk 'FNR == nr {a [$ 2] ++; Next} one [$ 2] & gt; 1 file file | Sort -2.2-K1    

  • Comments

    Post a Comment

    Popular posts from this blog

    php - PDO bindParam() fatal error -

    logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

    java - Why my included JSP file won't get processed correctly? -