1

I have a url which leads to a high size tar file, around 200gb , I need to extract one folder of that file in my linux system. Because of the large file size I don't want to download the entire file to my linux system. Also I don't have shh access to the source system.

Is there any way to extract only a small part of the tar.gz file?

2 Answers 2

0

To extract only particular directory you need to know the exact filenames. Wildcards do not work with tar. and the command will look like

curl -s -o - <URL>|tar xz /path/file1 /path/file2  ...
0

The tar format does not allow adressing a file (or a directory) directly - this is due to the fact, that tape archives were ment to be sequentially read from a backup medium.

What you can of course do, is stop the process after the relevant parts have been extracted. You would do something along the lines of

curl -o - 'http://your/url' | tar -xvz your_filter

This will download the file starting from the beginning and extract the relevant parts, once you have everything you need, you can stop the process to avoid downloading the rest.

Depending on what sort of access you have to the source server, you might even do better: Do you have PHP without save mode? If yes you can extract what you need via shell_exec and friends.

2
  • IMO you need to remove f from tar or use f - to use STDIN as input file Dec 10, 2018 at 8:59
  • 1
    @RomeoNinov Thanks, good catch - edited my answer. Dec 10, 2018 at 9:15

You must log in to answer this question.

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