>>>>> "Rick" == Rick Pasotto <[EMAIL PROTECTED]> writes:

Rick> On Tue, May 28, 2002 at 04:06:33PM -0300, O Senhor wrote:
>> How can i delete equal lines from a file, without sort it?  If i use
>> sort -u, the command clean up the repeat lines, but sort my file
>> (ascendent). I don't want this. I need my file in original form.

Try this perl script:

---- BEGIN ----
#!/usr/bin/perl -w

my %lines;

while (<>)
  {
    if (!defined $lines{$_})
      {
        print;
        $lines{$_} = "";
      }
  }
----- END -----

(lightly tested, performance may or may not suck.)

[...]

Rick> Have you looked at 'uniq'?

uniq still needs the lines to be sorted:

# man uniq

[...]

NAME
       uniq - remove duplicate lines from a *sorted* file

[...]

(emphasis mine)

-- 
Hubert Chan <[EMAIL PROTECTED]> - http://www.uhoreg.ca/
PGP/GnuPG key: 1024D/124B61FA
Fingerprint: 96C5 012F 5F74 A5F7 1FF7  5291 AF29 C719 124B 61FA
Key available at wwwkeys.pgp.net.   Encrypted e-mail preferred.

Attachment: pgpjGPOxfRfXz.pgp
Description: PGP signature

Reply via email to