Compress Files in Mac OS X Terminal, UNIX

Software

This post has been superseded by an updated one I wrote in 2010:
Unix file compression basics

Original Post

Quick way to compress files using the command line in Mac OS X (and most *nix).

  1. Open Terminal, cd to the required directory
  2. For multiple files, use tar -cf [destination name].tar [source file(s)]
  3. Then Gzip the sucker! gzip [source file].
  4. Optionally, for maximum compatibility, use uuencoding on the Gzip file:
    uuencode [source file] [source file] > [destination name].uu. Yes, type the file name twice.

Also, for a quick way to zip hundreds of files individually, just cd to the directory, then just gzip *.

Footer Notes:

  • UNIX is awesome :D. And yes I know Mac OS X isn't UNIX, let me have my fun.
  • This is one of the reasons I can never go back to Windows.

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!