Solved

Simple Perl Script to get Unique values from file

Posted on 2011-03-21
2
450 Views
Last Modified: 2012-06-21
It has been a few years since I have used Perl.  I have a text file with about 400 entries.  There are duplicates in the file.  An example of the input file would be.

smith
jones
taylor
smith
bruce

I need a output file with only the unique values.  An example of the output file

smith
jones
taylor
bruce

order is not important - I just need the unique values

0
Comment
Question by:jkteater
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 35183290
see
perldoc -q duplicate

perl -lne 'print unless $seen{$_}++' <inputfile > outputfile
0
 

Author Closing Comment

by:jkteater
ID: 35183386
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now