LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-01-2013, 08:18 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,224

Rep: Reputation: 49
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?

Last edited by stf92; 01-01-2013 at 08:22 PM.
 
Old 01-01-2013, 08:24 PM   #2
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 2,013

Rep: Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784
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.

Last edited by astrogeek; 01-01-2013 at 08:25 PM.
 
Old 01-01-2013, 08:46 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,224

Original Poster
Rep: Reputation: 49
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.
 
Old 01-01-2013, 08:50 PM   #4
beder
Member
 
Registered: Apr 2011
Posts: 82

Rep: Reputation: 28
Quote:
Originally Posted by stf92 View Post
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.
 
Old 01-01-2013, 09:01 PM   #5
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 2,013

Rep: Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784
Quote:
Originally Posted by stf92 View Post
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.
 
Old 01-01-2013, 09:09 PM   #6
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 2,013

Rep: Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784
Quote:
Originally Posted by stf92 View Post
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?
 
1 members found this post helpful.
Old 01-01-2013, 09:14 PM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,224

Original Poster
Rep: Reputation: 49
Yes, I have, and lasted much less than expected. Thanks again.
 
Old 01-01-2013, 10:09 PM   #8
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 2,013

Rep: Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784
Quote:
Originally Posted by stf92 View Post
Yes, I have, and lasted much less than expected. Thanks again.
Glad that worked!
 
Old 01-04-2013, 11:33 AM   #9
zerouno
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 272

Rep: Reputation: 82
Quote:
Originally Posted by stf92 View Post
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/{}" \;
 
Old 01-04-2013, 12:46 PM   #10
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 135

Rep: Reputation: 36
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
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Major Directory Trees Ztcoracat Linux - General 7 08-25-2012 08:40 PM
Best way to merge two directory trees with replace? legacyprog Linux - General 5 12-24-2011 09:15 PM
Merge directory trees mrwall-e Linux - Software 5 02-20-2011 09:37 AM
Q: on deleting directory trees n00bJoe Arch 3 03-09-2006 01:13 PM
How to keep 2 directory trees synchronised? hrr Linux - General 2 07-02-2003 01:01 PM


All times are GMT -5. The time now is 11:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration