2

I have a ton of txt.gz files on a network I want to ungzip and put into a tgz. I have enough disk space for the all compressed files, but not uncompressed.

The way I see it in my head is

tar -czf output.tgz --daemon
while read filename
do
    wget ftp://server/path/$filename.gz
    gunzip $filename.gz
    tar --add-to-daemon ./$filename
    rm $filename
done
tar --close-daemon

Is there a way to do this?

2 Answers 2

1

tar cannot modify compressed files:

$ tar Ajf archive1.tgz archive2.tar
tar: Cannot concatenate compressed archives

$ tar rjf archive1.tgz file.txt
tar: Cannot update compressed archives

If there isn't enough space for the uncompressed files, I think you can't do this.

0

You could easily do it the other way around, keep your text files individually gzipped and just tar them without additionally compressing the tar file. There are options to tar to concatenate archives or append files to an archive but you'd need to test to see if they work with an archive that is already compressed, since you don't have space to work with the full, uncompressed, input.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .