Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: output unique lines only

by swkronenfeld (Hermit)
on Dec 06, 2005 at 16:42 UTC ( [id://514539]=note: print w/replies, xml ) Need Help??


in reply to output unique lines only

No need for Perl, unless you're doing something more complicated. Type this from your *IX command line.

cut -d" " -f1 FileName | sort | uniq

Replies are listed 'Best First'.
Re^2: output unique lines only
by Perl Mouse (Chaplain) on Dec 06, 2005 at 16:53 UTC
    I'd go for a shell pipe as well, and it would be close to your suggestion. Except that I wouldn't use the final pipe, but use sort -u instead. But that's just a minor difference. I won't be handing out 'useless use of uniq' awards.
    Perl --((8:>*
Re^2: output unique lines only
by merlyn (Sage) on Dec 06, 2005 at 18:13 UTC
      the only reason to use sort and uniq in combination instead of "sort -u" that I can think of is to skip specific columns when looking for unique intances. example:
      ... RH_MEa0001bG06_5 710 14 16 Invalid starting position (14) RH_MEa0001bG06_4 710 125 12 GGGGGACACCTTCTCTCTCT... RH_MEa0001bG06_6 710 125 12 GGGGGACACCTTCTCTCTCT... ...
      sending a file containing this output to " | sort | uniq -f1" would compare each line and take the first instance that is unique (other than the column you want to skip, column 1 in this case) up to that point and give you :
      ... RH_MEa0001bG06_4 710 125 12 GGGGGACACCTTCTCTCTCT... RH_MEa0001bG06_5 710 14 16 Invalid starting position (14) ...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found