PROBLEM: I would like to be able to extract tar.gz files in a single step. This makes my question almost identical to this one: stackoverflow question for tar-gz.
My question is almost the same, but not the same, because I would like to do this on windows using 7zip command-line (or something similar) inside a bat file or ruby/perl/python script.
QUESTION: This seemingly simple task is proving to be more involved than the first appearance would make it out to be. Does anyone have a script that does this already?
Use the win32 port of tar.
Since you asked for 7-zip or something similar, I am providing an alternative tool that was written for your exact use case.
The tartool utility is a free and open source tool built using the .NET SharpZipLib library.
Example commmand to extract a
.tar.gz
/.tgz
- file,Disclaimer : I am the author of this utility.
Use
&&
to combine two commands in one step. Use 7zip portable (you will need 7z.exe and 7z.dll only)Old question, but I was struggling with it today so here's my 2c. The 7zip commandline tool "7z.exe" (I have v9.22 installed) can write to stdout and read from stdin so you can do without the intermediate tar file by using a pipe:
Where:
See the help file (7-zip.chm) in the install directory for more info on the command line commands and switches.
As noted by @zespri powershell will buffer the input to the second 7z process so can consume a lot of memory if your tar file is large. i.e:
A workaround from this SO answer if you want to do this from powershell is to pass the commands to cmd.exe: