Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Removing repeated lines from file

by broquaint (Abbot)
on Jun 24, 2003 at 11:44 UTC ( [id://268459]=note: print w/replies, xml ) Need Help??


in reply to Removing repeated lines from file

Time for one of them nifty one-liners
perl -ni -e 'print if $last ne $_; $last = $_' your_file
See. perlrun for more info.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Removing repeated lines from file
by YAFZ (Pilgrim) on Jun 24, 2003 at 11:54 UTC
    I´ve just created a file called repetitive.txt on my Cygwin system and used perl, v5.6.1 to try your one liner but it gave an error:

    Can't do inplace edit on repetitive.txt: Permission denied.

    And to my surprise the file was deleted. What can be the reason of that behaviour? Did I miss something?

      Perl on Windows can't use -i without an extension. I guess the same applies to Cygwin.

      Try -ni.bak instead.

      --
      John.

        Thanks, it worked without problems and errors :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found