xargs calculates what it believes to be the maximum length of a command line on your system, and executes the command line with enough arguments to make up that maximum command line. Thus, if it's executing the command more than once, you probably can't make it combine things any further.
Your workaround with tar -A is probably the method I'd use, unless there were specific patterns I could use with tar's --exclude option, or a list of files that I could use with --exclude-from. > -----Original Message----- > From: Jacob Fugal [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 17, 2003 16:35 > To: BYU Unix Users Group > Subject: [uug] Find and xargs > > > I'm writing a script to backup information here at work. However, > the files I want to back up are spread all over a gigantesque > directory tree. Within the same directory tree are many large files, > such as images, that I don't want to include in the backup tarball - > - for both time and space considerations. > > I though to approach this by using find to get the approriate files > and then feed them as command line parameters to tar, via xargs. > I've worked my find statement all out, and am happy with the list of > files it gives me. However, if I just do something like: > > find /root/of/tree [conditions] | xargs tar -cjf backup.tar.bz > > Then only the last 20 or so files end up in the tar ball. That's > because xargs ends up executing tar several times; not once for > each file, but more than once, which isn't what I want. > > I could create the empty archive first, then do tar -cAjf > backup.tar.bz as the xargs parameter to append files to the > archive. But this is slightly less efficient since the archive is > being opened and closed each time xargs appends more files -- which > in my case could be a hundred times or more. > > Is there a way to force xargs to execute the statement it's given > only once, or do I have to go with the alternative above? > > Jacob Fugal ____________________ BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________ List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
