28

gzipped files are awesome! they are the best compressed files I know, .rar and .zip are nowhere near , if you compare the compression ratios...

Generally I use Windows, does anyone know how can I gzip in Windows?? I have severe limits at the attachment sizes here, so anything that compresses more, is better.

2
  • 3
    By the way, gzip generally have lower compression rations than rar and 7z (albeit it de/compresses much faster), and it can only compress single files - generally tarballs when archiving (such as myfolder.tar.gz and it's generally suited for servers where you don't want to spend even a tiny bit of extra CPU if not necessary. For archiving I recommend 7z, it has a very good LZMA algorithm. And it's free/open source. Sep 26, 2012 at 12:16
  • 2
    Compression ratio is not the main rationale for gzip, the main advantages are: 1. it is the standard of the internet, standard for digital_preservation and for many serious systems (e.g. Apache Hive default); 2. it can operate in pipes, in stream mode, with no disk-usage. 3. it is free, transparent, it is not a black-box, no risk of Trojans, etc. 4. the compression ratios and CPU usage are reasonable when compared with other generic compression algorithms. May 24, 2020 at 12:07

3 Answers 3

38

7zip will handle gzip format. It also offers lzma compression which is much better than gzip.

If you want a command-line gzipper just like gzip in linux, try this

5
  • 15
    +1, but 7zip has a command line interface too. I use it for automated backups.
    – paxdiablo
    Sep 14, 2009 at 17:06
  • originally used WinRar, but switched to 7zip when I noticed it had shell integration as well. I also use a combinations of bash, nice, ls, xargs, and 7zip to uncompress bzip2 files and recompress them into 7z files on a linux web server (for Team Fortress 2 maps).
    – Powerlord
    Sep 14, 2009 at 17:56
  • 2
    @Powerlord That's cool, really, but WHY are you parsing ls directly? It does work most of the time, but you should really be using something like find, shouldn't you?
    – Wyatt Ward
    Jul 7, 2016 at 23:26
  • @Wyatt8740 It was a flat directory structure. Besides, ls -1 doesn't need parsing, you can pass it directly to xargs.
    – Powerlord
    Jul 8, 2016 at 6:37
  • 2
    @Powerlord so ls -1 can handle exotic stuff like newlines in filenames?
    – Wyatt Ward
    Jul 10, 2016 at 18:26
3

For those looking to compress multiple files into a .tar.gz file on Windows:

Since 2017, the tar (bsdtar) utility is available on Windows, both in PowerShell and in the basic Command Prompt (cmd).

For a summary of options, run tar --help, for a detailed list of options, visit the docs.

For example, to add the contents of my_directory to my.tar.gz you can do:

tar -czf my.tar.gz --directory my_directory *

where -czf combines the options for "create", "gzip", and "filename", respectively. --directory (or -C) changes directory before adding all content using * (or ., which also works in bash).

To inspect the file's contents:

tar -tf my.tar.gz

where -tf is "list", "filename"

And to extract the content into some_directory:

tar -xf my.tar.gz --directory=some_directory

where -xf is "extract", "filename"

For those that have git for windows installed: git bash includes both GNU tar (as opposed to bsdtar) and the gzip program.

5
  • 1
    tar -c stores all the files with the full specified path. Is this different on the Windows version?
    – Oskar Skog
    Nov 15, 2023 at 15:48
  • @OskarSkog you are right, I should have used --directory (or -C). I've updated the answer accordingly. On Windows, * does not exclude hidden files, as far as I know. Alternatively, . would also work, but places everyting under ./ in the archive. The end result after extraction is the same, but the . may be confusing when inspecting the archive.
    – djvg
    Nov 15, 2023 at 16:17
  • Does this actually work? tar -czf my.tar.gz --directory my_directory * I believe the * will be turned into filenames before tar moves into the specified directory. On a unix shell, I would do (cd my_directory && tar -czf ../my.tar.gz ./*) to accomplish what your example is trying to do. (Everything in parenthesis is run in a different process so you won't have to cd back)
    – Oskar Skog
    Nov 15, 2023 at 16:35
  • 1
    @OskarSkog Using bash on linux (ubuntu) the * fails, but . does work. Using powershell or command prompt on windows (10), both the * and . work as described above.
    – djvg
    Nov 15, 2023 at 20:31
  • @OskarSkog As for the -C, I believe it is "order sensitive", as mentioned in the gnu tar docs here and here, and in the docs for bsdtar (windows appears to use bsdtar)
    – djvg
    Nov 15, 2023 at 20:32
1

7zip and zgip are different things. You can't use 7zip to get the profit you want to get from the real gzip.

Try to use binaries from here http://gnuwin32.sourceforge.net/packages/gzip.htm

2
  • Hi, seems that you was wrong in say "You can't use 7zip", please correct it. The problem is not functional, the problem is reliability: non-open is non transparent, is a black-box. A black-box can be a trojan, etc. So, gzip is the most reliable. May 24, 2020 at 11:49
  • Hum.. Sorry, original gzip windows distribution is really old (2007!) and ugly for install. Not friendly... So, not useful for 99% of users. May 24, 2020 at 11:56

You must log in to answer this question.

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