LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   difference in files in two directories ignoring date/time (and subdirectories) (https://www.linuxquestions.org/questions/linux-general-1/difference-in-files-in-two-directories-ignoring-date-time-and-subdirectories-4175651185/)

funkytwig 03-30-2019 09:30 AM

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;(

Turbocapitalist 03-30-2019 10:10 AM

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"

funkytwig 03-30-2019 10:23 AM

Quote:

Originally Posted by Turbocapitalist (Post 5979490)
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?

Turbocapitalist 03-30-2019 10:28 AM

No problem.

Quote:

Originally Posted by funkytwig (Post 5979494)
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.

scasey 03-30-2019 10:33 AM

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.

Turbocapitalist 03-30-2019 10:43 AM

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.

scasey 03-30-2019 10:49 AM

Quote:

Originally Posted by Turbocapitalist (Post 5979504)
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!


All times are GMT -5. The time now is 04:23 AM.