How to display the contents of a gzip/gz file

Problem: You have a plain text file that has been compressed with the gzip command, and you'd like to display the file contents with the Unix/Linux cat or more commands.

Solution: Instead of using the cat or more commands, use their equivalents for working with gz files, the zcat and zmore commands.

For instance, if you want to display the contents of an Apache log file (which is a plain text file) that has been compressed with gzip, just use the zcat command, like this:

zcat access_log.gz

Of course almost any Apache log file will be large, and will scroll off the screen quickly, so you'll probably want to use the gzip equivalent of the more command, zmore, like this:

zmore access_log.gz

 

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.