LinuxCommandLibrary

bzless

View bzip2 compressed files without decompressing

SYNOPSIS

bzless [less_options] file...

PARAMETERS

file...
    One or more paths to bzip2 compressed files (typically ending in .bz2). These files are decompressed on the fly and displayed.

[less_options]
    Optional arguments that are passed directly to the underlying less command. This allows users to customize the pager's behavior, such as setting line numbers (-N), initiating searches (+/pattern), or controlling prompting.

DESCRIPTION

bzless is a convenient shell script that enables the less pager to display the contents of bzip2 compressed text files (.bz2 files) without requiring explicit decompression.

It functions by piping the output of bzcat (or bzip2 -dc), which decompresses the file to standard output, directly into the less command. This allows users to navigate, search, and view large compressed logs or data files as if they were uncompressed.

All standard less commands and functionalities, such as searching for patterns, scrolling, and marking positions, are available.

It's part of the bzip2 package and serves as a vital tool for system administrators and developers working with compressed data.

CAVEATS

bzless relies on the presence of both the bzip2 (or bzcat) utility and the less pager on the system. If the input file is not a valid bzip2 archive, bzip2 will report an error, and less will display an empty or error output. While efficient, decompressing large files on the fly might introduce a slight delay compared to viewing uncompressed files.

AUTOMATIC HANDLING WITH LESSOPEN

While bzless is a standalone command, many systems configure the LESSOPEN environment variable to automatically preprocess compressed files when less is invoked directly. For example, setting LESSOPEN="|/usr/bin/lesspipe.sh %s" or similar will allow less filename.bz2 to work without explicitly using bzless, as the lesspipe script will detect and decompress the file type.

HISTORY

bzless was introduced as a utility script accompanying the bzip2 compression program, which was developed by Julian Seward. The first stable version of bzip2 (version 0.9.0) was released in 1996.

The inclusion of convenience scripts like bzless (and bzcat, bzgrep) has been a standard practice with compression suites to enhance usability and integrate seamlessly with common Unix tools from early on.

SEE ALSO

less(1), bzip2(1), bzcat(1), zless(1), xzless(1)

Copied to clipboard