[TriLUG] create tar file from stdin
Kevin Hunter
hunteke at earlham.edu
Wed Feb 3 18:32:53 EST 2010
Careful. If you have names with special characters in them (like
spaces), that will mess up tar. Better to use a null-byte terminator.
Consider using a variant of find:
find . -maxdepth 1 -print0 | xargs -0 tar -cf myfile.tar
The -print0 predicate tells find to use the null-byte (\0) to delineate
files from each other, rather than space.
Then, xargs knows to quote the arguments to tar because of the -0.
man find
man xargs
Kevin
At 3:36pm -0500 Wed, 03 Feb 2010, 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
>
> Matthew Opoka wrote:
>> Anyone know of a way to read stdin with tar and create a tar file?
More information about the TriLUG
mailing list