Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
    wget ftp://server/path/$filename.gz
    gunzip $filename.gz
    tar --add-to-daemon ./$filename
    rm $filename
tar --close-daemon

Is there a way to do this?

share|improve this question

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.