[PLUG] Compare folders?

Carlos Konstanski ckonstanski at pippiandcarlos.com
Mon Dec 8 01:34:13 UTC 2008


On Sun, 7 Dec 2008, Carlos Konstanski wrote:

> Date: Sun, 7 Dec 2008 18:22:16 -0700 (MST)
> From: Carlos Konstanski <ckonstanski at pippiandcarlos.com>
> Reply-To: "General Linux/UNIX discussion and help;	civil and on-topic"
>     <plug at lists.pdxlinux.org>
> To: "General Linux/UNIX discussion and help;	civil and on-topic"
>     <plug at lists.pdxlinux.org>
> Subject: Re: [PLUG] Compare folders?
> 
> On Sun, 7 Dec 2008, John Jason Jordan wrote:
>
>> Date: Sun, 7 Dec 2008 17:18:52 -0800
>> From: John Jason Jordan <johnxj at comcast.net>
>> Reply-To: "General Linux/UNIX discussion and help;	civil and on-topic"
>>     <plug at lists.pdxlinux.org>
>> To: PLUG <plug at lists.pdxlinux.org>
>> Subject: [PLUG] Compare folders?
>>
>> For some reason the cp command has let me down, at least when performed
>> with Nautilus.
>>
>> I have a laptop where the /home folder contains 14.1 GB consisting of
>> 65,247 items. Using Nautilus I dragged the entire thing to a folder on
>> my desktop. I have done this many times in the past without problem.
>> But this time after the copying finished I discovered that the folder
>> on the desktop contains only 43,650 items, consisting of 7.8 GB. WTF?
>>
>> So to troubleshoot what is happening I need to figure out which files
>> from the laptop did not make it to the desktop. Hopefully, then I can
>> see a pattern which will shed light on what went wrong. I could compare
>> the folders manually, that is, if I don't mind spending the rest of my
>> life on the project.
>>
>> There must be a simple file compare utility that will work across two
>> computers connected by NFS. Any suggestions?
>> _______________________________________________
>> PLUG mailing list
>> PLUG at lists.pdxlinux.org
>> http://lists.pdxlinux.org/mailman/listinfo/plug
>>
>
> diff -r -s <folder1> <folder2>
>
> Carlos Konstanski

Or, better yet, if you just want the problem fixed, use rsync to make
a mirror copy of a directory tree:

rsync -av --delete folder1/ folder2/

Notice the trailing slashes.  These are vitally important in rsync.
You want to copy the contents of folder1 into folder2.  Always use
rsync like this to avoid disaster, especially when using the --delete
switch.  When not specifying --delete, you can get away with copying
folder1 itself to a destination (i.e. leaving off one or both trailing
slashes) without causing major data wiping.

Or, if you don't want to bother with a network mount, use rsync over
ssh:

rsync -e ssh -av --delete folder1/ user at desthost:folder2/

or if the source folder is on the remote host, and the destination is
local:

rsync -e ssh -av --delete user at sourcehost:folder1/ folder2/

Carlos Konstanski



More information about the PLUG mailing list