Using gunzip on Windows in command line
Asked Answered
H

4

8

I need to use gunzip (which is the decompression tool of gzip) in a terminal on Windows

I've downloaded gzip from here (first download link)

I installed it and added its /bin folder to my PATH variable, the gzip command works but gunzip is not even executable so I can't use it

gunzip content:

#!/bin/sh
PATH=${GZIP_BINDIR-'c:/progra~1/Gzip/bin'}:$PATH
exec gzip -d "$@"

Thanks

Hemingway answered 18/8, 2018 at 5:15 Comment(1)
I cannot believe how broken this feels LOLGeerts
H
6

I made it work

As I said I needed to install gzip and add its /bin folder to my PATH variable

Then edit the ProgramFiles/GnuWin32/bin/gunzip file using this (replace everything):

@echo off
gzip -d %1

and save it to .bat format so you now have a gunzip.bat file in your /bin folder

Now I can use gunzip in a terminal :)

Hemingway answered 18/8, 2018 at 5:30 Comment(1)
Be careful in case you are passing more than one argument this will not work by using %1 instead of %* only the first argument is taken into consideration.Henceforth
N
3

I have been using MobaXterm software in my local machine (Windows).
It works like Putty and WinSCP together and opens the local desktop in linux mode, thus it is easy for me to gunzip the *.gz type files.

Nicotiana answered 5/5, 2020 at 6:12 Comment(1)
I liked this solution. The terminal in MobaXterm has gunzip available. I had some trouble finding the Windows file system, but i found the drives under /media so I was able to navigate to /media/c/Users/myuser/Downloads and use gunzip on my downloaded file.Exhibit
R
2

At the time of writing, the last Gzip for Windows was released almost 17 years ago. Personally I wouldn't install anything this old on any machine I cared about (mainly due to security concerns): https://gnuwin32.sourceforge.net/packages/gzip.htm

Fortunately, 7-zip (which at the time of writing is under constant development) can be used as a replacement. Simply create a gunzip.bat file with the following content and place it somewhere in your PATH (adjust the 7z.exe path if necessary):

SETLOCAL
set file=%1
FOR %%i IN ("%file%") DO (
    "C:\Program Files\7-Zip\7z.exe" x %1 -o%%~di%%~pi
)

Note that parameter extensions are used to preserve the same working folder behavior as gunzip (which is - disregard and extract to the same folder as where the archive resides).

Rectrix answered 14/4 at 14:37 Comment(0)
H
1

The code you posted is bash, suitable for linux. You need to make a dos/command version of it to be run on windows i.e.

REM THIS IS CMD
PATH=c:/progra~1/Gzip/bin;%PATH%
gzip.exe -d "%*"

Since it is a different build anyway it is hard to say if all command line parameters are the same you are used with linux so maybe even with this .cmd or .bat you will not be able to work at the same way you do in a linux environment.

Henceforth answered 18/8, 2018 at 5:28 Comment(2)
Thank you for answering, I just found a solution and posted itMutualize
Or just use gzip -d ... from the windows cmd.Geerts

© 2022 - 2024 — McMap. All rights reserved.