Broken zcat on OS X

The zcat command line program in OS X has been broken for quite some time and is still that way in Snow Leopard. When trying to output the contents of a gzipped file, zcat appends .Z to the end of the file name that it’s given and outputs an error. The quick fix is to replace it with gzcat as follows:

$ cd /usr/bin
$ sudo mv zcat broken-zcat
$ sudo ln -s gzcat zcat

This process renames the original zcat program to broken-zcat and then creates a symbolic link called zcat that points to gzcat. This way, you don’t have to remember to specifically use gzcat. Running zcat will also use gzcat.