find -exec surprisingly slow

Paul A. Hoadley paulh at logicsquad.net
Sat Aug 14 18:50:20 PDT 2004


On Sat, Aug 14, 2004 at 08:11:54PM -0400, Garance A Drosihn wrote:

> Where is '.' in the above `find .' command?  Is it is on the same
> partition as /home/paulh/tmp/spam/sne/ ?
> 
> You may find it much faster to do something like:
>     mkdir usermail.new
>     chown user:group usermail.new
>     mv usermail usermail.bigspam
>     mv usermail.new usermail
>     cd usermail.bigspam
>     find . \! -atime +1 -exec mv {} ../usermail \;
> 
> My assumption there is that you have a LOT fewer "good files" than
> you have "bad files", so there will be fewer files to move.  But I
> am also making the assumption that all your files are in a single
> directory (and not a tree of directories), which may be a bad
> assumption.

All assumptions correct, and that is what I should have done.

> The thing to use is the '-J' option of xargs.  That way you can have
> the destination-directory be the last argument in the command that
> gets executed, and yet you're still moving as many files in a single
> `mv' command as possible.  E.g., change my earlier `find' command
> to:
>     find . \! -atime +1 -print0 | xargs -0J[] mv [] ../usermail
> 
> Check the man page for xargs for a description of -J

Will do.  Thanks for the tip.


-- 
Paul.

w  http://logicsquad.net/
h  http://paul.hoadley.name/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040815/fd42a6f3/attachment.bin


More information about the freebsd-questions mailing list