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 :)