LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-28-2011, 05:06 AM   #1
ameylimaye
LQ Newbie
 
Registered: Aug 2011
Posts: 25

Rep: Reputation: Disabled
how do u make unique set of elements?


hello,
i have a list of around 500 names..
each name repeats for atleast 3 or four times...but i want it to appear only once...can anyone help me in this.!

thank you in advance..
 
Old 09-28-2011, 05:09 AM   #2
arochester
Member
 
Registered: May 2006
Distribution: Debian
Posts: 615

Rep: Reputation: 98
Homework?
 
Old 09-28-2011, 05:16 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Take a look at the uniq command. If you have the names in a file, once per line you can simply try:
Code:
uniq <(sort filename)
The sorting is needed because uniq remove adjacent duplicates. If you don't want to sort the output, try awk as in:
Code:
awk '!_[$1]++' filename
 
Old 09-28-2011, 05:27 AM   #4
snooly
Member
 
Registered: Sep 2011
Posts: 124

Rep: Reputation: Disabled
sort filename.txt | uniq
 
Old 09-28-2011, 05:56 AM   #5
ameylimaye
LQ Newbie
 
Registered: Aug 2011
Posts: 25

Original Poster
Rep: Reputation: Disabled
Thank you!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pls help on how i can generate 4 digit random number that are unique within the set icylicious Programming 7 08-22-2006 01:00 PM
what make Slackware unique shanenin Slackware 55 07-09-2004 09:05 AM
Unique Set-up (at least I think it is) wolfhound Linux - Newbie 1 03-17-2004 03:48 PM
how to set up a unique mount point at a time.. 010668 Red Hat 4 03-10-2004 10:14 AM
Can I set unique backgrounds for each workspace in Bluecurve? dot hog Red Hat 4 10-25-2003 02:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration