I want to create a .tgz from the content of a directory. I also want to strip the leading "
./" from the tar'ed content.
I had done this as follows:
cd /path/to/files/ && find . -type f | cut -c 3- | xargs czf /path/to/tgz/myTgz.tgz
I learned recently that using
xargs may not be the best way to pull this off because
xargs may invoke
tar multiple times if the cmdline arg list gets too long, and I was advised to make use of
tar's ability to read a list of input files from stdin. I ended up finding this article on how to do this. However, I find that the recommendation...
cd /path/to/files/ && find . -type f | cut -c 3- | tar czf foo.tgz -T -
...seems to not be portable. It runs fine on my dev PC, but on a busybox target, I get the following error from running the same command:
tar: can't open '-': No such file or directory
So, my question: is there a truly portable/global way to invoke
tar to create a
.tgz by feeding it input files from stdin (as opposed to cmdline arguments)?
(It is not an option available to me to install alternatives to
tar such as
(Secondary question: Why does the "
-T -" argument to
tar denote "read files from
stdin"? From the
tar man page, all I could find was that "
get names to extract or create from FILE
... but I couldn't see any reference to a plain "