Unique Records from file ? - Unix

This is a discussion on Unique Records from file ? - Unix ; Hi, Its actually rather more suited to scripting question. there is sort command (and sort -u ) gives unique sort. why does not unix have separate unique command ? which will only output unique lines from fies ? (without disturbing ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Unique Records from file ?

  1. Unique Records from file ?

    Hi,

    Its actually rather more suited to scripting question.

    there is sort command (and sort -u ) gives unique sort.

    why does not unix have separate unique command ? which will only
    output unique lines from fies ?
    (without disturbing existing sorted/un-sorted order ?)

    -Raxit

  2. Re: Unique Records from file ?

    "Raxit@MyKavita.com" writes:

    > Hi,
    >
    > Its actually rather more suited to scripting question.
    >
    > there is sort command (and sort -u ) gives unique sort.
    >
    > why does not unix have separate unique command ? which will only
    > output unique lines from fies ?
    > (without disturbing existing sorted/un-sorted order ?)


    Have you tried uniq?

    --
    Måns Rullgård
    mans@mansr.com

  3. Re: Unique Records from file ?

    Måns Rullgård wrote:

    >> why does not unix have separate unique command ? which will only
    >> output unique lines from fies ?
    >> (without disturbing existing sorted/un-sorted order ?)

    >
    > Have you tried uniq?
    >


    he is not looking for a solution, he wants to know "why".

  4. Re: Unique Records from file ?

    On Fri, 02 May 2008 10:29:54 +0200, realitybites wrote:

    > Måns Rullgård wrote:
    >
    >>> why does not unix have separate unique command ? which will only
    >>> output unique lines from fies ?
    >>> (without disturbing existing sorted/un-sorted order ?)

    >>
    >> Have you tried uniq?
    >>
    >>

    > he is not looking for a solution, he wants to know "why".


    Why does he want to know why ?

    :-)
    AvK

  5. Re: Unique Records from file ?

    In <636be9b6-a0b0-42c1-bf56-c9f642a14d66@l25g2000prd.googlegroups.com> "Raxit@MyKavita.com" writes:

    > why does not unix have separate unique command ? which will only
    > output unique lines from fies ?
    > (without disturbing existing sorted/un-sorted order ?)


    If unix provided complete commands to do everything that everyone wanted
    to do, there would be too many commands.

    Instead, Unix provides only basic commands. If you want something more
    complicated, there's usually a way to do it by combining two or more
    of the basic commands.

    I think you can get what you want by combining sort, uniq, and grep.

    --
    John Gordon A is for Amy, who fell down the stairs
    gordon@panix.com B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"


  6. Re: Unique Records from file ?

    Raxit@MyKavita.com wrote:
    > Its actually rather more suited to scripting question.
    >
    > there is sort command (and sort -u ) gives unique sort.
    >
    > why does not unix have separate unique command ? which will only
    > output unique lines from fies ?
    > (without disturbing existing sorted/un-sorted order ?)


    If your file is already ordered, it does: "uniq".

    If your file is not already ordered, it can still be accomplished
    very conveniently, with this:

    awk '!seen[$0]++'

    In my opinion, that's concise and easy enough that it doesn't
    warrant having a special separate command to do it.

    - Logan

  7. Re: Unique Records from file ?

    On May 4, 6:00*am, Logan Shaw wrote:
    > Ra...@MyKavita.com wrote:
    > > Its actually rather more suited to scripting question.

    >
    > > there is sort command (and sort -u ) gives unique sort.

    >
    > > why does not unix have separate unique command ? which will only
    > > output unique lines from fies ?
    > > (without disturbing existing sorted/un-sorted order ?)

    >
    > If your file is already ordered, it does: *"uniq".
    >
    > If your file is not already ordered, it can still be accomplished
    > very conveniently, with this:
    >
    > * * * * awk '!seen[$0]++'
    >
    > In my opinion, that's concise and easy enough that it doesn't
    > warrant having a special separate command to do it.
    >
    > * *- Logan


    Tnx to all. Yeah, i was not looking for solution its "why" ?
    >Why does he want to know why ?

    curious too learn ! Anyway good humour !

    -Raxit


+ Reply to Thread