How can I build a tar from stdin?

tar
Kristopher Ives picture Kristopher Ives · Apr 8, 2010 · Viewed 95.1k times · Source

How can I pipe information into tar specifying the names of the file?

Answer

geekosaur picture geekosaur · Mar 4, 2011

Something like:

tar cfz foo.tgz -T -

But keep in mind that this won't work for all possible filenames; you should consider the --null option and feed tar from find -print0. (The xargs example won't quite work for large file lists because it will spawn multiple tar commands.)