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 04-18-2014, 04:51 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
Any easy way to compare files in two different trees?


Hi: that's more or less my question. I have /almacen and /slack12/almacen and I suspect they are identical (the trees). How would I know for certain?
 
Old 04-18-2014, 04:59 AM   #2
Phorize
Member
 
Registered: Sep 2005
Location: UK
Distribution: Slackware
Posts: 226

Rep: Reputation: 29
You can use diff recursively, such as:

diff -r pathtofirstdir pathtoseconddir
 
1 members found this post helpful.
Old 04-18-2014, 05:03 AM   #3
phenixia2003
Senior Member
 
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
Hello,

For this, I usually use this one :

Code:
$ diff -qr /almacen /slack12/almacen

--
SeB
 
Old 04-18-2014, 05:23 AM   #4
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Unbelievable. It works!
 
Old 04-18-2014, 10:11 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
There is something odd about this. How can diff compare binary files if he finds one while recursing? Every filename written on the console when I executed the command was a text file!
 
Old 04-18-2014, 10:51 AM   #6
TracyTiger
Member
 
Registered: Apr 2011
Location: California, USA
Distribution: Slackware
Posts: 528

Rep: Reputation: 273Reputation: 273Reputation: 273
Quote:
Originally Posted by stf92 View Post
There is something odd about this. How can diff compare binary files if he finds one while recursing? Every filename written on the console when I executed the command was a text file!
Simply try it.

Put identical binary files in each directory and see what happens.

Then change one of the binary files and see what happens.

Learn through experimentation... and the man pages.

EDIT: If you are referring to a different method of comparing directories, then use md5sum with the -c option. This is what Slackware uses to verify ISO directories.

Last edited by TracyTiger; 04-18-2014 at 11:26 AM.
 
1 members found this post helpful.
Old 04-18-2014, 11:28 AM   #7
neymac
Member
 
Registered: May 2009
Distribution: Slackware64-14.1
Posts: 138

Rep: Reputation: 19
If you want search for duplicated files on the same tree use FSlint, you can find it in http://slackbuilds.org. Compare binary files using diff is a very long task if you have big ones, diff compares files line by line. Or you can use the command line program Duff recommended by metaschima it's very fast

Last edited by neymac; 04-18-2014 at 02:52 PM. Reason: Add Duff
 
Old 04-18-2014, 12:07 PM   #8
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I recommend:
http://duff.dreda.org/
 
1 members found this post helpful.
Old 05-17-2014, 04:54 AM   #9
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by TracyTiger View Post
Learn through experimentation... and the man pages.
That's precisely the way I don't like. Experimentation is statistically incorrect. You will precisely know what a program does by just learning what the manufacturer has to say about it, as with anything else.
 
Old 05-17-2014, 05:15 AM   #10
schmatzler
Member
 
Registered: Jan 2011
Location: Germany
Distribution: Slackware64 -current + Multilib
Posts: 411

Rep: Reputation: 181Reputation: 181
"kompare" can also do that
 
Old 05-17-2014, 10:26 AM   #11
beder
Member
 
Registered: Apr 2011
Posts: 82

Rep: Reputation: 28
In my development environment I use meld to compare directory trees as well as individual files, as it gives much more options than simply a compare output (and I prefer its interface to kde's own Kompare)
 
1 members found this post helpful.
Old 05-17-2014, 10:36 PM   #12
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Actually, a tool which looks only for differences in size and date would be much more useful, at least in my case. That could be done by a simple algorithm that travels both trees, but this would imply the writing of a whole program, and not just a few lines of code.
 
Old 05-17-2014, 11:56 PM   #13
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 955

Rep: Reputation: 539Reputation: 539Reputation: 539Reputation: 539Reputation: 539Reputation: 539
I didn't test this, but maybe you can give it a try

Code:
diff <(cd tree1;t1=$(find -type f -name \* -exec ls -l {} \;);paste <(cut -d' ' -f5 <<<"$t1") <(cut -d' ' -f9- <<<"$t1")) <(cd tree2;t2=$(find -type f -name \* -exec ls -l {} \;);paste <(cut -d' ' -f5 <<<"$t2") <(cut -d' ' -f9- <<<"$t2"))
It will compare a list with size (field 5) and name (field 9),
the output will be the differences, so you can take a look closely.

Replacing -f5 with -f6-8 , the list will be date, hour and name.
 
Old 05-18-2014, 01:14 AM   #14
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
iNTENTIONALLY blanked by the author.

Last edited by stf92; 05-18-2014 at 01:27 AM. Reason: Error made by the poster.
 
Old 05-18-2014, 02:35 AM   #15
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I broke the command into several lines for greater legibility:
Code:
semoi@server:~/STORE1/soft/linux/comparo$ cat comparo02a.sh
tree1="/home/semoi/STORE1/sma_"
tree2="/home/semoi/juan/sma_"

diff <(cd $tree1 
t1=$(find -type f -name \* -exec ls -l {} \;)
paste <(cut -d' ' -f5 <<<"$t1") <(cut -d' ' -f9- <<<"$t1") \
) <(cd $tree2 
t2=$(find -type f -name \* -exec ls -l {} \;)
paste <(cut -d' ' -f5 <<<"$t2") <(cut -d' ' -f9- <<<"$t2")
)
If I comment the paste lines out then I get no output. Why?

Last edited by stf92; 05-18-2014 at 02:42 AM.
 
  


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
LXer: Trees, B-Trees, B+Trees and H-Trees LXer Syndicated Linux News 0 07-15-2013 02:11 PM
[SOLVED] How to compare a list of files in two directories: compare content and print size Batistuta_g_2000 Linux - Newbie 9 03-24-2013 07:05 AM
Reduction of common files in trees Skaperen Linux - Software 1 06-07-2012 10:44 PM
[SOLVED] Same files on distinct directory trees 0p3r4t4 Linux - General 1 11-25-2011 05:01 AM
Compare directory trees on seperate servers ? dhg1848 Linux - Server 4 11-26-2008 08:47 AM

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

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