How to View the Content of a Compressed Text File in Linux

Published February 22, 2026

How to view the content of a compressed text file that has been created with gzip, bzip2 or zip

Scenario and Use Cases

You have an Nginx access_log file that is gzipped. It is a text file. How can you view it without gunzipping or uncompressing it?

Or maybe you have an Apache access_log text file that is compressed using bzip2 or zip, and you want to read the contents of that file.

If you have any questions like this, this blog post is for you.

For this blog post, we will use Nginx's access.log which is an ASCII text file. This file is zipped in different compression formats including gzip, bzip2 and zip.

Create access.gz, access.bzip2 and access.zip

Create access.log

I picked up these 10 entries in my Nginx access log file and created a new file access.log. They are all visits from ChatGPT's OpenAI bot.

access.log

20.193.233.249 - - [19/Feb/2026:23:43:26 -0500] "GET /blog/toilets-in-japan/ HTTP/2.0" 200 12447 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "3.06"
40.67.183.184 - - [19/Feb/2026:23:46:39 -0500] "GET /blog/nginx-listen-http2-directive-deprecated/ HTTP/2.0" 200 10153 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "3.16"
23.98.142.177 - - [19/Feb/2026:23:47:56 -0500] "GET /blog/python-3-14-new-features/ HTTP/2.0" 200 11236 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "3.05"
23.98.142.177 - - [19/Feb/2026:23:47:57 -0500] "GET /blog/mac-address/ HTTP/2.0" 200 12217 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "3.28"
23.98.142.180 - - [19/Feb/2026:23:48:57 -0500] "GET /blog/install-python/ HTTP/2.0" 200 10068 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "3.05"
23.98.142.183 - - [19/Feb/2026:23:49:16 -0500] "GET /blog/find-ssl-certificate-expiration-date/ HTTP/2.0" 200 11286 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "3.24"
23.98.142.188 - - [19/Feb/2026:23:49:28 -0500] "GET /blog/usaco-palindrome-game/ HTTP/2.0" 200 10884 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "3.35"
115.245.122.54 - - [19/Feb/2026:23:52:58 -0500] "GET /blog/pix/yahoo_login_activity1.webp HTTP/2.0" 200 31534 "https://chatgpt.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36" "-"
52.173.235.86 - - [19/Feb/2026:23:56:46 -0500] "GET /blog/how-to-shorten-amazon-links/ HTTP/2.0" 200 10194 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "3.01"
23.98.142.188 - - [19/Feb/2026:23:58:41 -0500] "GET /blog/nginx-send-plain-text-responses/ HTTP/2.0" 200 9585 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot" "2.96"

Create access.log.gz, access.log.bz2 and access.log.zip

Run this to create access.log.gz

gzip -k access.log

Run this to create access.log.bz2

bzip2 -k access.log

Run this to create access.log.zip

zip access.log.zip access.log

Read access.log in access.log.gz

We can use zcat to to read access.log.gz. This works on most Linux systems.

zcat access.log.gz

On Linux and macOS, we can also use gzcat. gzcat is installed in my Mac.

gzcat access.log.gz

A third option is to use gzip -dc.

gzip -dc access.log.gz

A fourth method is to use zless. It simulates the less Linux command.

zless access.log.gz

A fifth method is to use zmore. It is similar to the zless command and simulates the more Linux command.

zmore access.log.gz

Read access.log in access.log.bz2

To read access.log inside access.log.bz2, we can use bzcat.

bzcat access.log.bz2

Read access.log in access.log.zip

To view the contents of access.log inside access.log.zip, we can use unzip -p.

unzip -p access.log.zip

Search all lines containing 'python' in access.log in gzip, bzip2 or zip file

To search for all lines containing a pattern, pipe it to grep like this:

zcat access.log.gz | grep 'python'

On the Mac:

gzip -cd access.log.gz | grep 'python'

bzip2

bzcat access.log.gz | grep 'python'

zip

unzip -p  access.log.zip | grep 'python'

Search all lines containing either 'python' or 'ssl' in access.log in gzip, bzip2 or zip file

To search for all lines containing either one string, pipe it to grep -E like this:

zcat access.log.gz | grep -E '(python|ssl)'

On the Mac:

gzip -cd access.log.gz | grep -E '(python|ssl)'

bzip2

bzcat access.log.bz2 | grep -E '(python|ssl)'

zip

unzip -p access.log.zip | grep -E '(python|ssl)'

Conclusion

Hope this blog post helped you in some way. If you would like more scenarios involving reading of log files contained in gzip, bzip2 or zip files, let me know and I'll add them to this blog post. Thanks for reading.

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Last Updated: February 22, 2026.     This post was originally written on February 19, 2026.