DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

OSXFAQ Mac OS X UNIX Tip-of-the-Day   back to index

Week 106 - New in Tiger (2 January 2006)

by Adrian Mayo - Editor, OSXFAQ

Monday - Zcat in now Gzcat

In versions of Mac OS X prior to 10.4 (Tiger), the zcat command was, like other z-commands, part of the GNU zip tool set. It could be used to directly display gzip compressed files.

But historically, zcat has existed to directly display files compressed by the Unix compress command (the extension used for this sort of file is .Z). The command was often overwritten by the GNU version.

In Tiger, the original zcat is preserved, and the GNU version is named gzcat. Therefore, always use gzcat unless the target file really was created by compress.

$ zcat /var/log/system.log.0.gz
zcat: /var/log/system.log.0.gz.Z: No such file or directory
$ zcat /var/log/system.log.0
zcat: /var/log/system.log.0.Z: No such file or directory
$ gzcat /var/log/system.log.0.gz
...
Jan  1 18:11:36 Sauron kernel[0]: AFP_VFS afpfs_mount: ...
Jan  1 18:11:49 Sauron kernel[0]: AFP_VFS afpfs_unmount: ...
...

Note that in pre Tiger systems gzcat was installed as zcat and gzcat. Use gzcat in scripts for portability.

Here's a reminder of the many z-variant commands available:

zcat     zdiff    zfgrep   zgrep   zmore    zprint
zcmp     zegrep   zforce   zless   znew

Note that znew can be used to recompress .Z files to .gz files. Also included the very useful zless, lacking in earlier versions of Mac OS X.

Remember too that bzip2 compressed files have a similar set of utilities.

bzcat   bzdiff   bzfgrep   bzip2        bzless
bzcmp   bzegrep  bzgrep    bzip2recover bzmore

Visit the Site of the Book of the Unix Tips:
Project 22 covers the gzcat command.
Project 27 shows how to compress files.


Discuss this trick in the Learning Center forum


Copyright © 2000-2010 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.