How to count duplicate the lines of a file by using Linux Shell Programming?
Posted on 09 July 2010 by Abidoon
Hi,
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!
Tags | count, Duplicate, file, lines, Linux, Programming, Shell, using

grep . anyFile | sort | uniq | wc
grep . anyFile | sort | wc
If a line is repeated, the output of the top grep code will be less than the bottom one.