Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: finding and deleting repeated lines in a file

by DamnDirtyApe (Curate)
on Jun 19, 2002 at 14:23 UTC ( [id://175694]=note: print w/replies, xml ) Need Help??


in reply to finding and deleting repeated lines in a file

perl -ne 'print unless $seen{$_}; $seen{$_}++' in.txt > out.txt

_______________
D a m n D i r t y A p e
Home Node | Email

Replies are listed 'Best First'.
Re: Re: finding and deleting repeated lines in a file
by marvell (Pilgrim) on Jun 19, 2002 at 14:50 UTC

    Which could be condensed to:

    perl -ne 'print unless $seen{$_}++' in.txt > out.txt

    and if you fancy replacing it directly, whilst makign a backup file:

    perl -i.bak -ne 'print unless $seen{$_}++' in.txt

    --
    Steve Marvell

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-25 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found