Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This has been asked several times but I can't seem to figure out the solution.

I have a tar.tgz archive which has .txt files in it. I need to extract a specific file t1.txt from it programatically in Win 7 in one step. I have tried Winzip 14.5, 7Zip and Tartool without success.

Winzip prompts for user input saying there is a .tar file inside the tat.tgz file. Do you want to extract the contents of it? I can't figure out if there is a switch that directs it to extract the contents always. 7 Zip extracts the contents of all .txt files onto the console rather than extracting it as files. Tartool doesn't allow extracting a specific file from the archive.

Please can someone help me on how to get this done?

Thanks, Ap

share|improve this question

Technically it is impossible to extract one file from a tgz archive without processing all files that are located "before" the wanted file.

This is because the used GNU zip compression is not random-access capable, you have to start decompressing at the beginning of the file and then continue as long as the data you want has not been extracted.

Therefore an optimized tool could only spare the data that comes after the file you want to extract (but I don't know such a tool).

share|improve this answer

If it's an option you can use WinRAR to extract a single file from an archive (I used gzip-1.6.tar.gz from here to test):

WinRar.exe e gzip-1.6.tar.gz "gzip-1.6\gzip.doc"

Use x instead of e if you want to extract files with full path.

Since you mentioned you want to do this programatically, remember of course that you can't redistribute the WinRAR, WinZIP etc. executables with your program.

share|improve this answer

You must log in to answer this question.

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