[TriLUG] create tar file from stdin
Carl Schaefer
trilug at carls.mm.st
Wed Feb 3 19:51:53 EST 2010
On Wed, 2010-02-03 at 15:36 -0500, Ben Coughenour wrote:
> Do you mean create a tar file that contains all the files who's names
> are listed on stdin? If so xargs is your friend.
>
> ls | xargs tar -cf myfile.tar
xargs can invoke the specified program multiple times, so if the file
list overflows one command line the resulting tar file will not contain
all the files. For building an archive from files on stdin, cpio is a
better choice because it supports that mode directly. However, if your
tar supports -r (aka --append), that should make the use of xargs safe.
Carl
> Matthew Opoka wrote:
> > Anyone know of a way to read stdin with tar and create a tar file?
> >
> > Regards,
> >
> > Matthew
> >
> >
> >
> > --
> > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> > TriLUG FAQ : http://www.trilug.org/wiki/Frequently_Asked_Questions
> >
>
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG FAQ : http://www.trilug.org/wiki/Frequently_Asked_Questions
More information about the TriLUG
mailing list