The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
compare columns from seven files and print the output smriti_shridhar Shell Programming and Scripting 7 06-11-2008 01:22 AM
Compare 2 files and output result in pop up window hongsh UNIX for Dummies Questions & Answers 2 05-23-2008 10:50 AM
Compare 2 files and give uniq output rauphelhunter Shell Programming and Scripting 1 05-12-2008 05:47 PM
awk to compare lines of two files and print output on screen chlfc Shell Programming and Scripting 3 03-24-2008 04:16 AM
compare two col from 2 files, and output uniq from file 1 pp56825 Shell Programming and Scripting 2 01-10-2008 11:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-14-2004
blt123 blt123 is offline
Registered User
  
 

Join Date: Feb 2002
Posts: 19
compare 2 files, output dups to file

I have two files that I want to compare and output a new file that will contain the duplicates. I have tried comm -12 and it doesn't work? Any help will be helpful.

Thanks,
Barbara
  #2 (permalink)  
Old 07-14-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
comm -12 should do what you want, provided you redirect the output to a new file, and (this is the biggy) ensuring that both input files are SORTED.


Code:
sort file1.txt > file1_sorted.txt
sort file2.txt > file2_sorted.txt

comm -12 file1_sorted.txt file2_sorted.txt > file3_dups.txt

more file3_dups.txt

Peace
ZB
  #3 (permalink)  
Old 07-15-2004
blt123 blt123 is offline
Registered User
  
 

Join Date: Feb 2002
Posts: 19
Thanks - sorting is the key obviously!

Much appreciated.....
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0