Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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
add comment

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

So if there isn't space for the uncompressed files, you can't do this.

share|improve this answer
add comment

Your Answer

 
discard

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.