Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
difference between two files
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rich Glazier  
View profile  
 More options Jun 7 2010, 2:28 pm
Newsgroups: fa.alpha-osf-managers
From: Rich Glazier <rglazier2...@yahoo.com>
Date: Mon, 07 Jun 2010 18:28:43 UTC
Local: Mon, Jun 7 2010 2:28 pm
Subject: difference between two files
I have two files something like this:

file 1
-------
1
2
4
5
6
8
9

file2
-----
1
2
3
4
5
6
7
8
9

i want to strip out only what's different in file 2 from file 1.  the output would only be 3 and 7.  i've tried using diff, sort, uniq, and comm but can't quite seem to get what i need.

any thoughts?

thanks!!

-Rich


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kjell Andresen  
View profile  
 More options Jun 7 2010, 2:40 pm
Newsgroups: fa.alpha-osf-managers
From: Kjell Andresen <kj...@dod.no>
Date: Mon, 07 Jun 2010 20:40:53 +0200
Local: Mon, Jun 7 2010 2:40 pm
Subject: Re: difference between two files

Rich Glazier <rglazier2...@yahoo.com> writes:
> I have two files something like this:
..
> i want to strip out only what's different in file 2 from file 1.  the
> output would only be 3 and 7.  i've tried using diff, sort, uniq, and
> comm but can't quite seem to get what i need.

> any thoughts?

$ diff --version
diff (GNU diffutils) 2.8.1

$ diff --suppress-common-lines file1 file2|grep ^\>|cut -c 3-80
3
7

Kjell


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "SUMMARY: difference between two files" by Rich Glazier
Rich Glazier  
View profile  
 More options Jun 8 2010, 6:08 pm
Newsgroups: fa.alpha-osf-managers
From: Rich Glazier <rglazier2...@yahoo.com>
Date: Tue, 08 Jun 2010 22:08:10 UTC
Local: Tues, Jun 8 2010 6:08 pm
Subject: SUMMARY: difference between two files
Thanks to all the responses I got. The one I went with was to sort and uniq the the files, and then compare them using 'comm'.

sort -u file1 > file1.sorted
sort -u file2 > file2.sorted
comm -13 file1.sorted file2.sorted

The '1' flag for comm says 'suppress lines unique to FILE1'
The '3' flag for comm says 'suppress lines that appear in both files'

Since I only cared about what was in file2 that wasn't in file1, these options worked.  In my example below the "1" option wouldn't really be necessary because there's nothing in file1 that isn't in file2, but for my real world files this covered both lines only in file1 and also lines both in file1 and file2. Or in-other-words, lines only in file2 that aren't in file1.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »