LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 07:18 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
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 07:22 PM.
 
Old 01-01-2013, 07:24 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
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 07:25 PM.
 
Old 01-01-2013, 07:46 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
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, 07: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, 08:01 PM   #5
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
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, 08:09 PM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
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, 08:14 PM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Yes, I have, and lasted much less than expected. Thanks again.
 
Old 01-01-2013, 09:09 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
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, 10:33 AM   #9
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 983

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
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, 11:46 AM   #10
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 687
Blog Entries: 1

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
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 07:40 PM
Best way to merge two directory trees with replace? legacyprog Linux - General 5 12-24-2011 08:15 PM
Merge directory trees mrwall-e Linux - Software 5 02-20-2011 08:37 AM
Q: on deleting directory trees n00bJoe Arch 3 03-09-2006 12:13 PM
How to keep 2 directory trees synchronised? hrr Linux - General 2 07-02-2003 12:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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