in reply to Comparing each line of a file to itself
Hello, Manju Moorthy, and welcome to the Monastery.
You could do this in Perl but is there any need when
$ sort file | uniq -cwould seem to be all you require? Just for fun here's a Perl equivalent
$ perl -ne '$x{$_}++;END {printf ("%5i %s", $x{$_}, $_) for keys %x};' file
|
|---|