Re: print one occurance for duplicate entries

From: Harry (harryooopotter_at_hotmail.co_)
Date: 11/29/05


Date: Tue, 29 Nov 2005 08:09:25 GMT

Ed Morton wrote...

>> Ed Morton wrote...
>>>awk 'NR%2{t=$0;next}!($3 in f){f[$3];print t"\n"$0}' file

>but almost all solutions that use getline are bad awk style at best or,
>more commonly, dangerously buggy or just plain wrong. Try this instead:
>
>awk '/dcm/{t=$0;next}!($0 in f){f[$0];print t"\n"$0}' file

I shouldn't compare the whole line. You are right, when I combined your
two solutions together, it became this.

  awk '/dcm/{t=$0;next}!($3 in f){f[$3];print t"\n"$0}' file

And it worked great when I examined a small portion of input vs
output. As I said, the input is 40000 lines long. I'll checked more
lines visually.

Thank you very much.



Relevant Pages

  • Re: print one occurance for duplicate entries
    ... Ed Morton wrote... ... dangerously buggy or just plain wrong. ... you'd be much better off trying to fix that (e.g. ...
    (comp.unix.shell)
  • Re: Teachers College
    ... I find that surprising when I compare it to German "Mannes". ... Indeed it's just plain wrong, but apparently that's what the OED claims. ...
    (alt.usage.english)
  • Re: date of a file
    ... Ed Morton wrote: ... > christrier wrote: ... >> i want to compare two files by comparing their dates. ... The path can be a filename, it does not have to be a directory name. ...
    (comp.unix.shell)
  • Re: su or su -
    ... > logged in as a regular user, trying to install a new source package. ... > Compare to the following, in which the hyphen is ommitted: ... Plain old sudo saves another step - exit - and is far, ...
    (linux.redhat.misc)