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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Duplicate Lines 1

Status
Not open for further replies.

johngiggs

Technical User
Oct 30, 2002
492
US
I have a file which has a few duplicate lines. I would only like to print the duplicates, but I'm having a hard time thinking about how to accomplish this task. I was thinking of using a for loop, but I can't seem to get it to work. I am open to using a shell script, awk, or perl. Any help would be greatly appreciated.

Thanks,

John
 
something like that could get you started:

sort johngig.txt | uniq -c | nawk '$1 > 1 { $1=""; print}'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
good catch, Ygor!

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top