Home » Odeon Blogs » Calvin, Weaver »

zcat bug on mac osx

zcat bug on mac osx

There's a bug on Mac OS X's (Lion) default zcat utility that appends a ".Z" suffix to your .gz files automatically.

I discovered it when running a shell script to copy/download a remote postgresql database dump zipped up in .gz format and when I tried to unarchive it.

  1. calvin$ ./fetch_server_db.sh
  2. remote db dump (gzip)
  3. copying remote dump to localhost
  4. pg_dump_2011-10-17_16-06-36.db.gz 100% 881KB 220.2KB/s 00:04
  5. deleting remote file
  6. loading dump in local db
  7. ALTER SCHEMA
  8. zcat: pg_dump_2011-10-17_16-06-36.db.gz.Z: No such file or directory

THE FIX

Fortunately for us, there's another utility on Mac OS X called gzcat which works perfectly fine.  And since most of my colleagues use the same zcat command in my shell script, I decided to replace my broken zcat utility like that:-

  1. calvin$ sudo mv /usr/bin/zcat /usr/bin/broken-zcat
  2. calvin$ sudo ln -s /usr/bin/gzcat /usr/bin/zcat
A temporary bandaid of sorts until I can dig deeper to find out what's wrong with my particular version of zcat on Mac OS X.  Just so we know, my broken zcat version is:-

  1. calvin$ broken-zcat --version
  2. broken-zcat 1.3.12
  3. Copyright (C) 2007 Free Software Foundation, Inc.
  4. Copyright (C) 1993 Jean-loup Gailly.
  5. This is free software. You may redistribute copies of it under the terms of
  6. the GNU General Public License <http: www.gnu.org="" licenses="" gpl.html="">.
  7. There is NO WARRANTY, to the extent permitted by law.
  8. Written by Jean-loup Gailly.</http:>
This goes into my TODO list.


Category: OS X


Tagged as: lion zcat

Discussion

  1. rjp on Aug 04, 2012 - 10:26 said:

    It's not really broken, it's just in POSIX mode. The man page explains: "In POSIX mode zcat will append .Z to all filenames that do not have that suffix."

    rjp> zcat --version
    zcat 1.3.12
    Copyright (C) 2007 Free Software Foundation, Inc.
    Copyright (C) 1993 Jean-loup Gailly.


  2. You are right. Thanks for catching this in the apple docs. Much appreciated!




Leave a Comment :

(required)


(required)




(required)








Page generated in: 0.23s