zmore
Page through a compressed file without decompressing it to disk
By CMD Script Team · 4 min read · Last updated
zmore [FILE...]Options
| Flag | Description |
|---|---|
(no flags) | zmore takes no meaningful options of its own; it wraps more's paging behavior over decompressed input |
SPACE | Interactive command: advance to the next page (inherited from more) |
b | Interactive command: skip back one page (inherited from more, where supported) |
q | Interactive command: quit the pager |
multiple files | When given several compressed files, zmore pages through them in sequence |
Distribution compatibility
- Ubuntu (via gzip package)
- Debian (via gzip package)
- Fedora
- Arch
- macOS (via gzip formula/BSD userland; behavior may vary)
What it does
zmore lets you page through the contents of a compressed file (typically .gz or
.Z) one screen at a time, without first decompressing it to a separate file on disk. It
works by decompressing the data on the fly and streaming it into the more pager, so
from the user's perspective it behaves just like running more on the plain-text version
of the file, minus the cleanup step. It's a niche, largely legacy tool today — most
users reach for zless (built on less) instead, since less offers backward
scrolling and search that more lacks.
Beginner examples
zmore file.txt.gz— page through a compressed file's contentszmore file.log.gz— same, for a compressed log filezmore a.gz b.gz— page through two compressed files, one after another- Press
spaceto advance a page,qto quit, while viewing
zmore application.log.gz
Advanced examples
- Quickly inspect a rotated, compressed log without decompressing it to disk first:
zmore /var/log/app.log.2.gz - Page through several compressed log rotations in one session:
zmore app.log.1.gz app.log.2.gz app.log.3.gz - Compare with the modern equivalent that supports backward scrolling:
zless app.log.gzinstead ofzmore app.log.gz - Fall back to
zmorein minimal environments whereless/zlessisn't installed butmoreis guaranteed to exist.
zmore /var/log/syslog.1.gz
Common mistakes
- Expecting
zmoreto support the same rich navigation asless/zless— being unable to scroll backward is a real limitation of the underlyingmorepager. - Manually decompressing a file first (
gunzip file.gz) just to page through it, whenzmore file.gzaccomplishes the same thing in one step without leaving a decompressed copy behind. - Assuming
zmoreworks on any archive format — it's specifically for the compressed formatsgzip/compressproduce (.gz/.Z), not general archives like.taror.zip. - Reaching for
zmoreout of habit whenzlessis available and installed, missing out on better search and backward navigation for no reason.
Tips
- Check whether
zlessis available first (which zless) — it's almost always the better choice when both exist. - Use
zcat file.gz | grep patterninstead ofzmorewhen you already know what you're searching for and don't need interactive paging. - Remember
zmorenever leaves a decompressed file on disk, which makes it a safe choice for quickly checking large compressed logs on a disk-constrained system.
Best practices
- Prefer
zlessoverzmorewhenever it's available, sinceless's backward scrolling and search make it strictly more capable for interactive viewing. - Use
zmore/zlessinstead of manualgunzip+more/less+ cleanup whenever you just need to look at a compressed file's contents, not permanently decompress it. - In scripts or automated contexts, avoid interactive pagers altogether and use
zcatpiped intogrep/awkfor non-interactive processing.
Try it yourself
A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.
Real-world use cases
- Quickly checking the contents of an old, compressed, rotated log file during an incident investigation without cluttering the disk with a decompressed copy.
- Reviewing a compressed archive of historical build logs page by page on a server with limited free disk space.
- Working on a minimal or legacy system where
less/zlessisn't installed butmoreandzmoreare guaranteed to be present.
Common interview questions
- What's the difference between
zmoreandzless?zmorepages compressed output throughmore, which only scrolls forward;zlesspages it throughless, which supports backward scrolling and searching —zlessis generally preferred when available. - Does
zmorewrite a decompressed copy of the file to disk? No, it decompresses the data in a stream and feeds it directly to the pager, so no intermediate decompressed file is created. - Why might you use
zmoreinstead ofgunzipfollowed bymore?zmoredoes it in a single step and never leaves a leftover decompressed file that you'd otherwise need to clean up afterward.
Frequently Asked Questions
What's the difference between zmore and zless?
zmore pages through decompressed output using the more pager, which only scrolls forward and has more limited navigation. zless uses less, which supports backward scrolling, searching, and other richer navigation. Where available, zless is generally the more pleasant tool; zmore exists mainly for systems or scripts that only expect more.
Does zmore create a temporary decompressed file on disk?
No — zmore decompresses the data in memory (streaming it through the same logic as zcat) and feeds it directly to the more pager, so you never end up with a leftover decompressed copy on disk the way you would with gunzip file.gz followed by more file.
Why would I use zmore instead of just gunzip then more?
gunzip file.gz followed by more file leaves a decompressed copy on disk that you have to clean up, and requires two commands. zmore does it in one step without ever writing an uncompressed file, which matters when disk space is tight or you just want a quick look.
Cheat sheet
Download a quick-reference cheat sheet for zmore.