LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-06-2010, 08:56 AM   #1
chudster
LQ Newbie
 
Registered: May 2008
Posts: 22

Rep: Reputation: 0
diff question: how to show only missing files


I have a question on using diff. I have two files that contain directory/file listings: d11.lis and d11.lis from a previous day. I am not interested in files that changed, or were added, I just want to see a list of files that are missing on day two.

Any ideas?

Thanks in advance.
 
Old 10-06-2010, 09:03 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I would use comm to do this and not diff.

Assuming both files are sorted: comm -23 file1 file2 will show entries that are missing in file2.

Hope this helps.
 
Old 10-06-2010, 09:19 AM   #3
chudster
LQ Newbie
 
Registered: May 2008
Posts: 22

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by druuna View Post
Hi,

I would use comm to do this and not diff.

Assuming both files are sorted: comm -23 file1 file2 will show entries that are missing in file2.

Hope this helps.
Awesome, thanks druuna!
 
Old 10-06-2010, 09:19 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome
 
Old 10-07-2010, 04:02 PM   #5
chudster
LQ Newbie
 
Registered: May 2008
Posts: 22

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by druuna View Post
Hi,

I would use comm to do this and not diff.

Assuming both files are sorted: comm -23 file1 file2 will show entries that are missing in file2.

Hope this helps.

Actually I think that just comm -3 file1 file2 is what shows entries missing in file2 (that's a -3, not a -23).
 
Old 10-08-2010, 01:29 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Maybe it gives you the results you want, but it doesn't show files that are only missing from day 2 (file2) as stated in your first post.

1 - suppress lines unique to FILE1
2 - suppress lines unique to FILE2
3 - suppress lines that appear in both files

Examples:
Code:
# cat file1
0
1
A
B
W
X

$ cat file2
0
A
B
W
Z

$ comm -23 file1 file2
1
X

$ comm -3 file1 file2
1
X
        Z
As you can see, -23 shows 1 and X, which are missing in file2. -3 also shows Z, which is present in file2 but missing in file1.

Anyway, which of these you actually need depends on the actual requirements.

Hope this clears things up a bit.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
diff question: how to show only missing files chudster Linux - Software 1 10-07-2010 06:44 PM
diff files elainelaw Linux - Software 2 07-23-2009 05:52 AM
diff two files noir911 Linux - Server 3 03-25-2009 05:00 PM
is it possible to diff ps files? markhod Linux - General 8 09-05-2005 12:17 AM
.diff files? jtsai256 Linux - Newbie 1 09-28-2003 02:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration