Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'awk', nawk', sed'? Not sure 2

Status
Not open for further replies.

mwesticle

Programmer
Nov 19, 2003
51
US
OK. Here's my dilemma... I have a file with a bunch of 12-byte "ID's" on it. It looks like this:

111111111111
999999999999
222222222222
999999999999
333333333333
222222222222

...and so on.

Anyway, here's the criteria: I want to take this file, do "something" to it, and, when that "something" is done, I want a file that contains just the duplicated ID's from this file. So in the example above, the output file would look like this:

999999999999
222222222222

The duplication in this file is sometimes non-consecutive, so a "sort" may have to happen first. Anyway, what's the best way to go about this, do you think? I figured I'd solicit some expert opinions... Thanks for the input!
 
how about

sort -u filename, i think it is almost the same as sort filename|uniq
 
But not the same as sort filename | uniq -d which outputs only duplicate lines

CaKiwi
 
adamcpng, sort -u is the same as sort | uniq but not the same as sort | uniq -d.
The goal is to retrieve only the duplicates lines.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top