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..

Recommended Answers

All 3 Replies

hi,

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

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

Member Avatar for Kwetal

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.