LinuxCommandLibrary

xzless

View xz-compressed files without uncompressing

TLDR

View a compressed file

$ xzless [path/to/file]
copy

View a compressed file and display line numbers
$ xzless --LINE-NUMBERS [path/to/file]
copy

View a compressed file and quit if the entire file can be displayed on the first screen
$ xzless --quit-if-one-screen [path/to/file]
copy

SYNOPSIS

xzless [less options] [xz options] [file…]

PARAMETERS

+NUM or +/PATTERN
    Start less at line NUM or search for PATTERN

-c, --stdout, --cat
    Decompress to stdout; skips less

-z, --decompress
    Ignored (for xzmore compatibility)

--help
    Print usage and exit

--version
    Print version and exit

DESCRIPTION

xzless is a specialized pager utility for viewing XZ-compressed files without manual decompression. It pipes decompressed output from xzcat directly to less(1), enabling efficient navigation, searching, and scrolling through large compressed text files or data streams.

Invoke xzless file.xz to display content interactively. For multiple files, it cycles through them, showing filenames like less. If no files are given, it reads from stdin, ideal for piped compressed data. It handles concatenated .xz streams by decompressing until EOF.

Key benefits include on-the-fly decompression, conserving disk space and time—perfect for XZ-archived man pages, logs, or source code in Linux environments. Supports most less features (search with /, :n next file) and single-letter xz options, though conflicts prioritize less. Not for binary files, as pager assumes text.

Common in XZ Utils package, it enhances workflows where compressed files are prevalent, outperforming generic less on .xz by avoiding temp files.

CAVEATS

Options common to less and xz give less precedence; no less -t support. Memory-limited by less for huge files. Text-only; binaries may display poorly. Conflicts possible with multi-letter xz options.

EXAMPLES

xzless /usr/share/man/man1/xzless.1.xz
xzless file1.xz file2.xz
zcat log.gz | xz -c | xzless
xzless -c archive.xz > plain.txt

NOTES

Honors LESSOPEN, LESSCLOSE env vars. For editing, decompress first with xz -d.

HISTORY

Introduced in XZ Utils 4.999.3beta (2008-2009) by Lasse Collin as part of LZMA/XZ tooling suite, replacing lzless. Merged into mainline 5.0.0 (2009); maintained for modern Linux/BSD distros.

SEE ALSO

less(1), xz(1), xzcat(1), xzmore(1), zless(1)

Copied to clipboard