LinuxCommandLibrary

zmore

View compressed text files one screen at a time

TLDR

Open a compressed file

$ zmore [path/to/file.txt.gz]
copy

Display the next page of the file
$ <Space>
copy

Search for a pattern in the file (press to go to next match)
$ </>[regex]
copy

Exit
$ <q>
copy

Display interactive command help
$ <h>
copy

SYNOPSIS

zmore [options] [file...]

PARAMETERS

file...
    One or more compressed or uncompressed text files to view. If no files are specified, zmore reads from standard input.

-NUMBER
    Specify the number of lines per screen to display. This option is passed directly to the underlying more command.

-d
    Display helpful messages at the bottom of the screen, such as "[Press space to continue, 'q' to quit.]", instead of just ringing the bell when an invalid key is pressed. Passed to more.

-l
    Do not pause after a form feed (control-L) character. Passed to more.

-s
    Squeeze multiple blank lines into a single blank line. This helps in viewing files with excessive whitespace. Passed to more.

+/pattern
    Start displaying text two lines before the first occurrence of the specified pattern in each file. The pattern can be a regular expression. Passed to more.

DESCRIPTION

zmore is a script that allows users to view compressed text files one screen at a time, similar to the more command. It automatically detects and decompresses files compressed with gzip, compress, or pack before piping their content to more. This enables quick browsing of large compressed logs or documentation without manual decompression.

When multiple files are specified, each file is displayed sequentially. zmore intelligently determines the compression type based on the file extension and invokes the appropriate decompression utility (e.g., gzip -dc or uncompress -c).

CAVEATS

zmore is essentially a wrapper script around more and decompression utilities (like gzip and uncompress). This design means it inherits the limitations of more, particularly its inability to scroll backward easily, which is a significant disadvantage compared to zless. It also relies on the external decompression tools being present in the system's PATH. While it handles common compression formats like .gz, .Z, and .tgz/.tar.gz, it may not support all compression types.

OPERATION PRINCIPLE

zmore operates by creating a pipeline: it first decompresses the input file(s) using an appropriate utility (e.g., gzip -dc for .gz files or uncompress -c for .Z files), and then pipes the decompressed standard output directly to the more command. This means that zmore effectively passes all interactive commands and options to the underlying more program, giving users a familiar interface for navigating the file content.

HISTORY

zmore emerged as part of the gzip compression utility package in the early 1990s. Its creation was driven by the increasing need to efficiently view the contents of compressed files without first decompressing them manually. It provided a convenient solution by leveraging existing standard Unix tools: more for paging and gzip/uncompress for on-the-fly decompression. While zless (a similar wrapper for less) later offered more advanced navigation, zmore remained a simple and effective tool for basic compressed file viewing.

SEE ALSO

more(1), less(1), zless(1), gzip(1), zcat(1), uncompress(1)

Copied to clipboard