Crashalot
Crashalot

Reputation: 34523

How to untar large tarball file within disk space constraints?

We need to extract five files from a tarball file that contains over 30 files and expands to about 60 GB upon unpacking. Unfortunately, we only have about 20 GB free on the machine. The five files needed only take about 5 GB unpacked.

Is there a way to extract only these five files within our disk space constraints?

Using tar xvjf <archive> <file> doesn't seem to work.

Thanks!

Upvotes: 2

Views: 3416

Answers (2)

rob hale
rob hale

Reputation: 11

On the local server: nc server 9999 | tar -zxvf -

On the remote server: nc -l 9999 < yourfile.tar.gz

Upvotes: 1

Dave Newman
Dave Newman

Reputation: 1016

GNU tar has a feature to delete elements from a tarball. This would allow you to, in theory, trim the tarball down to the 5 files you need. This feature is described as being slow, and on a tarball that size, probably very slow. It is not something you want to try if you don't have a backup of the tarball.

Copied from GNU tar's manual is this example:

To delete all versions of the file ‘blues’ from the archive ‘collection.tar’ in the ‘practice’ directory, make sure you are in that directory, and then,

$ tar --list --file=collection.tar
blues
folk
jazz
rock
$ tar --delete --file=collection.tar blues
$ tar --list --file=collection.tar
folk
jazz
rock

Upvotes: 1

Related Questions