How to count duplicate the lines of a file by using Linux Shell Programming?

Discussion in 'Programming/Scripts' started by Gregoryfried, Mar 16, 2011.

  1. Gregoryfried

    Gregoryfried New Member

    I'm new to linux and to shell programming. I have an assignment to create a shell script that shows all the folders, sub folders and files of the current directory. LS does this. But I must count how many duplicate lines each file has, and show the line that is repeated the most times in each file.

    I really have no idea where to start. How can I read/compare lines within a file?

    Thanks in advance!
  2. alleks

    alleks Member

  3. gerr1t

    gerr1t New Member

    cat filename | sort | uniq -c

    Good luck :)

Share This Page