'How to extract specific file from partially downloaded tar file

I have a large tar file but it could not be downloaded completely as the browser crashed when verifying the download. Is it possible to extract some files from this tar?

I am able to view the files using tar -tf abc.tar and this shows the directories and folders

a/
a/b/
a/b/1
a/b/2

However if I use tar -xvf abc.tar a/b/1 it gives

tar: Error opening archive: Failed to open abc.tar

Is there any way to only extract the available files in the tar in such a case?



Solution 1:[1]

Simple answer is "it can't be done". The answer stands behind the zip algorithm and how the saved file is structured. Some detailed explanations you can find here https://en.wikipedia.org/wiki/ZIP_(file_format) but I will extract and present you the most important ones:

A ZIP file is correctly identified by the presence of an end of central directory record which is located at the end of the archive structure in order to allow the easy appending of new files. If the end of central directory record indicates a non-empty archive, the name of each file or directory within the archive should be specified in a central directory entry, along with other metadata about the entry, and an offset into the ZIP file, pointing to the actual entry data. This allows a file listing of the archive to be performed relatively quickly, as the entire archive does not have to be read to see the list of files. The entries within the ZIP file also include this information, for redundancy, in a local file header. Because ZIP files may be appended to, only files specified in the central directory at the end of the file are valid. Scanning a ZIP file for local file headers is invalid (except in the case of corrupted archives), as the central directory may declare that some files have been deleted and other files have been updated.

So if you don't have the end of the file downloaded you can't read any of it. I will post again the most important sentence to make things clear:

"A ZIP file is correctly identified by the presence of an end of central directory record which is located at the end of the archive structure in order to allow the easy appending of new files. "

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 D A