Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: a way to do 'sort|uniq'

by merlyn (Sage)
on Aug 02, 2005 at 15:40 UTC ( [id://480240]=note: print w/replies, xml ) Need Help??


in reply to a way to do 'sort|uniq'

cat file.txt|sort|uniq
Deleting the useless use of cat, and using a far-underused sort flag, I'd type that as:
sort -u file.txt

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: a way to do 'sort|uniq'
by ikegami (Patriarch) on Aug 02, 2005 at 15:48 UTC
    That search doesn't result in anything particularly useful. The first match, the one which looks the most promising and the one which refers to you by name, is a broken link. A cached version is readable. It would be nice if you provided a link to your document instead of having us wade through broken links trying to figure out what you mean.
Re^2: a way to do 'sort|uniq'
by tlm (Prior) on Aug 03, 2005 at 03:48 UTC

    ...the useless use of cat...

    What do we have here?! It sure looks like a useless use of "use of"1. What's wrong with "the useless cat"? :-)

    1Or, if I'm to practice what I preach, a useless "use of".

    the lowliest monk

        Ah! Something like "PNS Syndrome"!

        Thanks for the cluebrick!

        the lowliest monk

Re^2: a way to do 'sort|uniq'
by jch341277 (Sexton) on Aug 02, 2005 at 16:30 UTC

    I was generalizing the construct - I usually do something like:

    $ tail +2 file.txt|tr -dc '[0-9\n]'|sort|uniq -c|sort -rnk 1

    I realize that the 'cat' would be useless in the simplified example that I gave, but the point was I wanted a way to do that same type of thing all in one step with perl.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-10-09 01:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (44 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.