>_cmd.script

zmore

Page through a compressed file without decompressing it to disk

Compression

By CMD Script Team · 4 min read · Last updated

SYNTAX
zmore [FILE...]

Options

Command options and flags
FlagDescription
(no flags)zmore takes no meaningful options of its own; it wraps more's paging behavior over decompressed input
SPACEInteractive command: advance to the next page (inherited from more)
bInteractive command: skip back one page (inherited from more, where supported)
qInteractive command: quit the pager
multiple filesWhen 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 contents
  • zmore file.log.gz — same, for a compressed log file
  • zmore a.gz b.gz — page through two compressed files, one after another
  • Press space to advance a page, q to 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.gz instead of zmore app.log.gz
  • Fall back to zmore in minimal environments where less/zless isn't installed but more is guaranteed to exist.
zmore /var/log/syslog.1.gz

Common mistakes

  • Expecting zmore to support the same rich navigation as less/zless — being unable to scroll backward is a real limitation of the underlying more pager.
  • Manually decompressing a file first (gunzip file.gz) just to page through it, when zmore file.gz accomplishes the same thing in one step without leaving a decompressed copy behind.
  • Assuming zmore works on any archive format — it's specifically for the compressed formats gzip/compress produce (.gz/.Z), not general archives like .tar or .zip.
  • Reaching for zmore out of habit when zless is available and installed, missing out on better search and backward navigation for no reason.

Tips

  • Check whether zless is available first (which zless) — it's almost always the better choice when both exist.
  • Use zcat file.gz | grep pattern instead of zmore when you already know what you're searching for and don't need interactive paging.
  • Remember zmore never 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 zless over zmore whenever it's available, since less's backward scrolling and search make it strictly more capable for interactive viewing.
  • Use zmore/zless instead of manual gunzip + 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 zcat piped into grep/awk for 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/zless isn't installed but more and zmore are guaranteed to be present.

Common interview questions

  • What's the difference between zmore and zless? zmore pages compressed output through more, which only scrolls forward; zless pages it through less, which supports backward scrolling and searching — zless is generally preferred when available.
  • Does zmore write 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 zmore instead of gunzip followed by more? zmore does 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.