tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* difference between two files
@ 2010-06-07 18:21 Rich Glazier
  2010-06-08 22:07 ` SUMMARY: " Rich Glazier
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Glazier @ 2010-06-07 18:21 UTC (permalink / raw)
  To: Tru64-UNIX-Managers

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* SUMMARY: difference between two files
  2010-06-07 18:21 difference between two files Rich Glazier
@ 2010-06-08 22:07 ` Rich Glazier
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Glazier @ 2010-06-08 22:07 UTC (permalink / raw)
  To: Tru64-UNIX-Managers

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.



----- Original Message ----
From: Rich Glazier <rglazier2002@yahoo.com>
To: Tru64-UNIX-Managers@ornl.gov
Sent: Mon, June 7, 2010 12:21:52 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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-08 22:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 18:21 difference between two files Rich Glazier
2010-06-08 22:07 ` SUMMARY: " Rich Glazier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox