Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
04-18-2014, 04:51 AM
|
#1
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Rep:
|
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?
|
|
|
04-18-2014, 04:59 AM
|
#2
|
Member
Registered: Sep 2005
Location: UK
Distribution: Slackware
Posts: 226
Rep:
|
You can use diff recursively, such as:
diff -r pathtofirstdir pathtoseconddir
|
|
1 members found this post helpful.
|
04-18-2014, 05:03 AM
|
#3
|
Senior Member
Registered: May 2006
Location: France
Distribution: Slackware
Posts: 1,052
|
Hello,
For this, I usually use this one :
Code:
$ diff -qr /almacen /slack12/almacen
--
SeB
|
|
|
04-18-2014, 05:23 AM
|
#4
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
Unbelievable. It works!
|
|
|
04-18-2014, 10:11 AM
|
#5
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
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!
|
|
|
04-18-2014, 10:51 AM
|
#6
|
Member
Registered: Apr 2011
Location: California, USA
Distribution: Slackware
Posts: 528
|
Quote:
Originally Posted by stf92
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.
|
04-18-2014, 11:28 AM
|
#7
|
Member
Registered: May 2009
Distribution: Slackware64-14.1
Posts: 138
Rep:
|
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
|
|
|
04-18-2014, 12:07 PM
|
#8
|
Senior Member
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982
|
|
|
1 members found this post helpful.
|
05-17-2014, 04:54 AM
|
#9
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
Quote:
Originally Posted by TracyTiger
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.
|
|
|
05-17-2014, 05:15 AM
|
#10
|
Member
Registered: Jan 2011
Location: Germany
Distribution: Slackware64 -current + Multilib
Posts: 411
Rep:
|
"kompare" can also do that
|
|
|
05-17-2014, 10:26 AM
|
#11
|
Member
Registered: Apr 2011
Posts: 82
Rep:
|
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.
|
05-17-2014, 10:36 PM
|
#12
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
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.
|
|
|
05-17-2014, 11:56 PM
|
#13
|
Member
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 955
|
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.
|
|
|
05-18-2014, 01:14 AM
|
#14
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
iNTENTIONALLY blanked by the author.
Last edited by stf92; 05-18-2014 at 01:27 AM.
Reason: Error made by the poster.
|
|
|
05-18-2014, 02:35 AM
|
#15
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 05:11 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|