bzless

file viewinglinux
The bzless command is one of the most frequently used commands in Linux/Unix-like operating systems. bzless View bzip2 compressed files using the less pager

Quick Reference

Command Name:

bzless

Category:

file viewing

Platform:

linux

Basic Usage:

bzless [options] [arguments]

Common Use Cases

    Syntax

    bzless [options] file.bz2

    Options

    Option Description
    +[num] Start at line number [num]
    -i, --ignore-case Ignore case in searches
    -N, --LINE-NUMBERS Display line numbers
    -S, --chop-long-lines Chop (truncate) long lines rather than wrapping
    -M, --LONG-PROMPT Show more detailed prompt
    -n, --line-numbers Suppress line numbers

    Note: bzless supports most options that the less command accepts, as it is a wrapper around bunzip2 and less.

    Examples

    How to Use These Examples

    The examples below show common ways to use the bzless command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    #

    Basic Examples:

    # View a compressed file with paging
    bzless file.txt.bz2
    # Search within a compressed file by pressing '/' bzless large_log.bz2 # Then type your search pattern followed by Enter
    # Navigate through the file using less commands bzless document.bz2 # Use arrow keys, Page Up/Down, Space, Enter, etc.

    Advanced Examples:

    # Open at a specific line (line 100)
    bzless +100 large_file.bz2
    # Display line numbers bzless -N file.txt.bz2
    # Ignore case in searches bzless -i file.txt.bz2 # Then type your search pattern followed by Enter
    # Use with other tools find . -name "*.bz2" -exec bzless {} \; # View multiple files bzless file1.bz2 file2.bz2 # Press :n to go to the next file, :p for previous

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    Key Features:

    The bzless command provides a convenient way to view bzip2 compressed files without manually decompressing them:

    • View compressed text files with paging capabilities
    • Search within compressed files using less search functionality
    • Navigate through files with keyboard shortcuts
    • Supports all the features and options of the less pager
    • Preserves disk space by not requiring explicit decompression

    Common Less Navigation Commands:

    • Space or Page Down: Move forward one screen
    • b or Page Up: Move backward one screen
    • Down Arrow or Enter: Move forward one line
    • Up Arrow: Move backward one line
    • g: Go to the first line
    • G: Go to the last line
    • /pattern: Search forward for 'pattern'
    • n: Repeat the last search forward
    • N: Repeat the last search backward
    • q: Quit

    Implementation Details:

    bzless is a shell script that acts as a wrapper. It combines:

    • bunzip2 to decompress the input file
    • less to display the content with paging capabilities

    Usage Tips:

    • Use -i for case-insensitive searches in log files
    • Use -S when viewing files with very long lines
    • Use +G to start viewing from the end of the file (useful for logs)
    • Set the LESS environment variable to customize less behavior for all less-based commands including bzless
    • For multiple files, use :n and :p to navigate between them

    Limitations:

    • Not suitable for viewing binary or non-text content
    • Requires the bzip2 and less packages to be installed
    • Memory usage increases with larger files as they are decompressed in memory

    Related Commands

    These commands are frequently used alongside bzless or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the bzless command works in different scenarios.

    $ bzless
    View All Commands