The ...| tar c --null -T -
solution above is the best if you have adequate memory (i.e. the file list fits into your memory easily (in most cases, this is true)). However, xargs does have a place if you are memory-constrained, but you have to use it appropriately so that the multiple tar invocations have no ill effect.
To compress, you may use:
find . -type f -size -1024k | xargs tar c | gzip > archive.tar.gz
This results in a file of concatenated tar archives, gzipped together into the resulting file (you may also use cz
and omit | gzip
as concatenating gzip archives is still valid gzip, but you lose a tiny bit of compression, or quite a bit of compression if you use bzip2 or xz instead of gzip).
To extract the resulting file you have to use the --ignore-zeros
or -i
option of tar to not only extract the first archive:
tar xizf archive.tar.gz