LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Comparing two directory trees. Any utility? (http://www.linuxquestions.org/questions/slackware-14/comparing-two-directory-trees-any-utility-4175443733/)

stf92 01-01-2013 07:18 PM

Comparing two directory trees. Any utility?
 
Slackware 14.0

Hi:
I copied (cp -r) /STORE1, which is on a DVD, to the hard disk. I forgot to use the -a option, which preserves dates and after that, I modified some of the files. As a result, all the files in hdd://STORE1 have the current date!

I cannot just recopy the DVD or else I would lose the modifications. What I need then is a program that compares two trees and prints the names of the files with different time-stamps (or different sizes). Is there any linux command like that?

astrogeek 01-01-2013 07:24 PM

I use
Code:

diff -rq tree1 tree2 | sort
To compare trees within my own project environments.

This will show you all files that are different, or files that only exist in one tree or the other.

This might do what you need.

stf92 01-01-2013 07:46 PM

Thank you. I expect it does not compare the file contents but only there sizes or time-stamps or something else. Else, it would take too long.

beder 01-01-2013 07:50 PM

Quote:

Originally Posted by stf92 (Post 4860938)
I expect it does not compare the file contents but only there sizes or time-stamps or something else. Else, it would take too long.



Bad news from "man diff"
Code:


DESCRIPTION
      Compare FILES line by line.


astrogeek 01-01-2013 08:01 PM

Quote:

Originally Posted by stf92 (Post 4860938)
Thank you. I expect it does not compare the file contents but only there sizes or time-stamps or something else. Else, it would take too long.

Yes it does compare their contents.

astrogeek 01-01-2013 08:09 PM

Quote:

Originally Posted by stf92 (Post 4860938)
Thank you. I expect it does not compare the file contents but only there sizes or time-stamps or something else. Else, it would take too long.

I keep diff -rq aliased as rdiff on my own systems and use it on some large trees across NFS mounts - it is 'fast enough'. I expect that the speed of the DVD drive would be more of a limiting factor.

Of course only you can judge what is 'too long' for your own use. But you only have to type a few characters to find out.

Have you tried it yet?

stf92 01-01-2013 08:14 PM

Yes, I have, and lasted much less than expected. Thanks again.

astrogeek 01-01-2013 09:09 PM

Quote:

Originally Posted by stf92 (Post 4860951)
Yes, I have, and lasted much less than expected. Thanks again.

Glad that worked!

zerouno 01-04-2013 10:33 AM

Quote:

Originally Posted by stf92 (Post 4860925)
Slackware 14.0

Hi:
I copied (cp -r) /STORE1, which is on a DVD, to the hard disk. I forgot to use the -a option, which preserves dates and after that, I modified some of the files. As a result, all the files in hdd://STORE1 have the current date!

I cannot just recopy the DVD or else I would lose the modifications. What I need then is a program that compares two trees and prints the names of the files with different time-stamps (or different sizes). Is there any linux command like that?

to reset timestamp
Code:

# cd /STORE1
# find . -exec touch -r "{}" "/destSTORE1/{}" \;


jmccue 01-04-2013 11:46 AM

Maybe do something like this under both directories:
Code:

find . -type f -exec ls --time-style='+%Y%m%d-%H%M%S' -l '{}' \;
format the two files via awk(1), sort and do a diff of the two files you created

John


All times are GMT -5. The time now is 11:34 PM.