LinuxQuestions.org
Review your favorite Linux distribution.
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 03-30-2019, 09:30 AM   #1
funkytwig
Member
 
Registered: Jun 2016
Posts: 46

Rep: Reputation: Disabled
difference in files in two directories ignoring date/time (and subdirectories)


Basically, I want to compare the contents of (mainly binary) files in 2 directories. And if files are missing/extra.

I want to ignore timestamps and directories and don't want to do this recursively.

Been googling for a while but can't find a solution;(
 
Old 03-30-2019, 10:10 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,292
Blog Entries: 3

Rep: Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718
The utility diff does it as a matter of course. It is so simple that there will not be any guides, tutorials, or howtos to find on the net.

Code:
diff ./A/ ./B/
That will show you which files are only present in one directory or the other as well as files of the same name which different in content between the two directories. See "man diff"
 
1 members found this post helpful.
Old 03-30-2019, 10:23 AM   #3
funkytwig
Member
 
Registered: Jun 2016
Posts: 46

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
The utility diff does it as a matter of course. It is so simple that there will not be any guides, tutorials, or howtos to find on the net.

Code:
diff ./A/ ./B/
That will show you which files are only present in one directory or the other as well as files of the same name which different in content between the two directories. See "man diff"
Thanks, you are a star. 'man diff' is very sparse on Centos 7, , does say 'compare files line by line' which I guess describes it but a little clarification in man page may be good. Where should I suggest this?
 
1 members found this post helpful.
Old 03-30-2019, 10:28 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,292
Blog Entries: 3

Rep: Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718
No problem.

Quote:
Originally Posted by funkytwig View Post
Thanks, you are a star. 'man diff' is very sparse on Centos 7, , does say 'compare files line by line' which I guess describes it but a little clarification in man page may be good. Where should I suggest this?
It's there near the end, but definitely not clear or terribly obvious:

Quote:
FILES are 'FILE1 FILE2' or 'DIR1 DIR2' or 'DIR FILE' or 'FILE DIR'. ...
Solving it would not be hard, technically. I'd get the source RPM and add the line(s) you need to the manual page and then make a diff of the changes, and attach the diff to the bug report you submit to the CentOS Bug Tracker. They can then kick it upstream.
 
Old 03-30-2019, 10:33 AM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,723

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
From man diff on CentOS 7:
Quote:
The full documentation for diff is maintained as a Texinfo manual. If the info and diff programs are properly installed at your site, the command

info diff

should give you access to the complete manual.
info diff does give a more complete description of how diff works on directories.
 
Old 03-30-2019, 10:43 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,292
Blog Entries: 3

Rep: Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718
Sorry to be negative about info pages, but I gave up wasting time on them years ago. Nearly all of them are just placeholders and then those very few that aren't placeholders are split up into many uselessly small pages strung together with an exceedingly poor navigation system. If info pages were plain HTML 2.0 and navigable in any text-based browser, I'd be all over them, but as it stands, I don't see a future for info pages. As far as I can tell they exist only to drag down the quality and quantity of GNU/Linux documentation and make FreeBSD look good by comparison.

However, either way, it is something to bring up with the diff maintainers for CentOS in this context.
 
Old 03-30-2019, 10:49 AM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,723

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
Quote:
Originally Posted by Turbocapitalist View Post
Sorry to be negative about info pages, but I gave up wasting time on them years ago. Nearly all of them are just placeholders and then those very few that aren't placeholders are split up into many uselessly small pages strung together with an exceedingly poor navigation system. If info pages were plain HTML 2.0 and navigable in any text-based browser, I'd be all over them, but as it stands, I don't see a future for info pages. As far as I can tell they exist only to drag down the quality and quantity of GNU/Linux documentation and make FreeBSD look good by comparison.

However, either way, it is something to bring up with the diff maintainers for CentOS in this context.
I don't disagree at all. I just wanted to note that in this case, the explanation of how diff works with directories was much clearer there that in the man page.

That it did what it does with directories was new information to me, for which I thank you. Very cool!
 
  


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
[SOLVED] File time stamp and time as printed by date showing difference MahendraL Linux - Newbie 9 04-19-2015 05:02 AM
[SOLVED] Find Files Named with 'text.rpt' in All Directories and Subdirectories using Perl newbi2014 Linux - Newbie 9 12-08-2014 10:22 PM
Find directories that have two subdirectories in them-- PLEASE help pierceogden Programming 6 04-06-2012 08:47 PM
how to convert windows date and time to unix date and time jitupatil_2007 General 8 03-31-2008 05:58 AM

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

All times are GMT -5. The time now is 10:18 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