[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A silly question about tar



Tyler Smith <tyler.smith@mail.mcgill.ca> wrote:

> On 2007-03-17, Douglas Allan Tutty <dtutty@porchlight.ca> wrote:
> >
> > You use find to spit out a list of the files you want (you _may_ be
> > able to just use ls -1 .tar), pipe that through xargs.  Something
> > like this:
> >
> > 	ls -1 .tar.gz | xargs tar [tar options -f ]
> >
> > for each line of input it receives, xargs will tack it to the end
> > of the command line you give it (in the example, it will be tacked
> > on after the -f).
> >
> > I have not tested this, YMMV.
> 
> I have, and unfortunately it doesn't work. The result is the same as
> the original problem with the regular * expansion:
> 
> tyler:tar-> find ./ -name '*.tar.gz' | xargs echo
> ../one.tar.gz ./three.tar.gz ./two.tar.gz
> 
> replace echo with tar, and you see that tar is going to try and
> extract the second and third archives from within the first archive,
> which fails. I think you have to use some sort of loop, as other
> posters have suggested.

It works with 'xargs -n1' (and no need for -1 to ls)

Regards,
Andrei
-- 
If you can't explain it simply, you don't understand it well enough.
(Albert Einstein)



Reply to: