Would it be more efficient to use rsync to get filestats instead of using the 'find' command? I would like to know how big a directory is on a filesystem, but this directory has millions of small files. I was wondering if rsync would be more efficient than find when using "-n" options. TIA
On Mon, 2008-10-13 at 22:50 -0400, Mag Gam wrote:> Would it be more efficient to use rsync to get filestats instead of > using the 'find' command? I would like to know how big a directory is > on a filesystem, but this directory has millions of small files. I was > wondering if rsync would be more efficient than find when using "-n" > options.I assume that by "filestats" you mean stat(2) information for each file, not aggregate statistics. My guess is that "find" would be faster than "rsync -n" because it doesn't send the stat information to other processes like rsync does. In addition, "find -printf" has a configurable output format, while the "rsync --list-only" output format is fixed. Matt
Thanks. Does rsync use stat()? does find use stat() when running with printf? I think the stat() is the most expensive part. On Tue, Oct 14, 2008 at 12:30 AM, Matt McCutchen <matt@mattmccutchen.net> wrote:> On Tue, 2008-10-14 at 00:28 -0400, Mag Gam wrote: >> Great. Thanks matt. I was using the find method, but I want to find a >> better way to get my directory sizes. I suppose a find -printf may >> work. > > "find -printf" will give you the sizes of the directories (as lists of > entries) themselves. If you want subtree sizes, use "du". > > Matt > >
On Tue, 2008-10-14 at 07:31 -0400, Mag Gam wrote:> Does rsync use stat()? does find use stat() when running with printf? > I think the stat() is the most expensive part.Rsync and "find -printf" both use stat(2). Matt
Thanks Matt. I suppose I could use rsync to know how big a directory is then...right? rsync --progress -avzL -n /source /foo That should give me the total number of bytes to transfer On Wed, Oct 15, 2008 at 3:03 PM, Matt McCutchen <matt@mattmccutchen.net> wrote:> On Tue, 2008-10-14 at 07:31 -0400, Mag Gam wrote: >> Does rsync use stat()? does find use stat() when running with printf? >> I think the stat() is the most expensive part. > > Rsync and "find -printf" both use stat(2). > > Matt > >
On Sat, 2008-10-18 at 20:55 -0400, Mag Gam wrote:> Thanks Matt. I suppose I could use rsync to know how big a directory > is then...right? > > rsync --progress -avzL -n /source /foo > > That should give me the total number of bytes to transferThat will work, but --progress seems to be pointless on a dry run, and you might like to pass --stats to get some additional information. Matt