Fedora Linux Support Community & Resources Center
  #1  
Old 25th December 2006, 08:01 PM
fed.linuxgossip Offline
Registered User
 
Join Date: Dec 2005
Posts: 80
Compare and list out only the uncommon files.

I have two files ........

root@server1 [~]# cat a.txt
john
tim
dan
peter
maria

root@server1 [~]# cat b.txt
john
tim
angel
dan
william
monica
peter
juliet
bruce
maria

Now I want to compare the two files and list out only those entries that is not present in both files say to a file named c.txt

The result should be like.
root@server1 [~]# cat c.txt
angel
william
monica
juliet
bruce



Please advice with which command/script can this be achieved.
Reply With Quote
  #2  
Old 26th December 2006, 01:23 AM
whitesuit Offline
Registered User
 
Join Date: Dec 2006
Posts: 42
use diff:

$ diff a.txt b.txt

then create a script to filter only the lines you want. Or man diff, it probably already does that for you with some switch.
__________________
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." - Linus Torvalds
"When I do this, some people think that it's because I want my ego to be fed, right? Of course, I'm not asking you to call it "Stallmanix"!" - Richard Stallman
Reply With Quote
  #3  
Old 26th December 2006, 02:20 AM
fed.linuxgossip Offline
Registered User
 
Join Date: Dec 2005
Posts: 80
Hi,

I found that the sdiff command does the trick.

root@server34 [~]# sdiff -s b.txt a.txt
angel <
william <
monica <
juliet <
bruce <
Reply With Quote
Reply

Tags
compare, files, list, uncommon

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare files and settings 2 Fedora PCs Polly_31 Using Fedora 0 25th June 2009 04:38 PM
Compare kernel .config files anika200 Using Fedora 2 19th June 2009 09:58 PM
Compare two files of different script application? Lascolb Using Fedora 3 30th April 2008 04:41 PM
Is there a way to compare two html files for differences in the two? Shadow Skill Using Fedora 2 7th December 2004 10:47 AM


Current GMT-time: 19:34 (Wednesday, 23-04-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat