We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,621 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Remove Duplicates Lines Without unique in UNIX

Hi all,

How to remove duplicates in Unix. Suppose i have file like bellow
1,primary,a
1,secondary,b
2,secondary,c
2,secondary,d

i want the output as
1,primary,a
2,secondary,c

Please give me the solution for this command..

Thanks in Advance..

4
Contributors
3
Replies
1 Day
Discussion Span
8 Months Ago
Last Updated
4
Views
New Abhi
Newbie Poster
1 post since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

hi,

before I give the solution, I'd be glad you explain the logic behind the selection you wish to accomplish.

Watael
Junior Poster
121 posts since Apr 2012
Reputation Points: 4
Solved Threads: 26
Skill Endorsements: 2

That is the exact job of uniq. Why would you want to exclude that from your solution set?

L7Sqr
Practically a Posting Shark
849 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7

Clearly, the lines

1,primary,a
1,secondary,b

are different. What is the reason why the upper one should be retained in the output and the lower omitted? The same question for the lines

2,secondary,c
2,secondary,d

How do you determine the "uniqueness" of input lines?

Kwetal
Newbie Poster
14 posts since Oct 2010
Reputation Points: 26
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0626 seconds using 2.64MB