Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Comparing each line of a file to itself

by hippo (Bishop)
on Jan 13, 2019 at 13:02 UTC ( [id://1228465]=note: print w/replies, xml ) Need Help??


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 -c

would 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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228465]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2024-04-23 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found