On Tue, 17 May 2005 11:41:43 -0500
florin at iucha.net (Florin Iucha) wrote:

> On Tue, May 17, 2005 at 11:15:22AM -0500, Josh Trutwin wrote:
> > I'm trying to use the following command to create an archive of
> > all the SPAM folders I have on my email system:
> > 
> > find /usr/local/sites/ -iname '.SPAM*' | xargs tar cjvf
> > spam_20050517.tar.bz2
> > 
> > There are IMAP folders called SPAM, Not Spam, etc.  The command
> > works ok until it encounters something like "Not Spam" then the
> > space trips the command up.
> > 
> > tar: /usr/local/sites/www.davidtrutwin.com/users/dlt/.spam.Not:
> > Cannot stat: No such file or directory
> > tar: Spam: Cannot stat: No such file or directory
> >
> > Is there an easy fix to this?
> 
> find $dir -print0 | xargs ...

Almost, one detail missing:

find /usr/local/sites/ -iname '.SPAM*' -print0 | xargs --null tar cjvf
spam_20050517.tar.bz2 

The --null arguement to xargs is required.

The other post which had a tar being spawned for every file was very
undesirable as the above command may archive close to 100k files!

Thanks!

Josh