Tar Command Help

Is it possible to untar a file so it's size reduces while it uncompresses its contents. I have limited space on my mount point and was wondering if we can untar as a stream in other words the size of tarball reduces as it uncompresses the contents.

Thanks

Not that I know of... But what is stopping to leave/put to tar file in a different filesystem?

No space on any other filesystem on this host to hold the tarfile.

Thanks

Time to do some cleaning up then... If its that full you are living dangerously...

<file.tar.gz gunzip -c | tar xvf -

The gunzip reads from stdin, that is directed from file.tar.gz .
It also can read from a pipe:

ssh -qnx remotehost cat file.tar.gz | gunzip -c | tar xvf -

Without compression:

ssh -qnx remotehost cat file.tar | tar xvf -

You want to purge the files from the tar as they're extracted?

You could try listing the files in the tar, then extracting & deleting each one in turn. Something like:

filelist=$(tar -tvf archive.tar)
for file in $filelist
do
   tar -xf archive.tar "$file"
   tar --delete -f archive.tar "$file"
done

(untested, assuming GNU tar)

1 Like