bzmore command in Linux with examples

bzmore command in Linux is used as a filter for CRT viewing of bzip2 compressed files, which are saved with .bz2 suffix. In simple words, using ‘bzmore’, the content of the file can be viewed on the screen without uncompressing the file. bzip2 is a block-sorting file compressor which compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. bzip2 compresse files more effectively than the older Deflate (.zip and .gz) and LZW (.Z) compression algorithms, but is slower.
While the bzip2 command line utility can be used to compress files, there are many other tools that let you perform basic tasks – like searching, comparing, and more without the need to uncompress them. bzmore is just like ‘more‘ command in Linux but it is mainly used for compressed bz2 files. bzmore allows examination of compressed files one screenful at a time on the terminal and pauses, with the bottom line printing “–More–” on the screen. For performing further tasks on the terminal, various options are available.

Syntax :

bzmore [ name ...]

Example: A text file named GFG.txt is compressed via bzip2. After the compression, the file is saved as GFG.txt.bz2. In this file, for instance contains numbers ranging from 1 to 40 like this:

1
2
3
.
.
.
40

Now, To view the contents of this file execute the following command:

bzmore filename.bz2

view content of file through bzmore

This command prints a screenful of text on the terminal.

Options: These options are executed on the ‘–More–‘ statement present in the end of the terminal.

  • d : It displays 11 more lines on the terminal. It means a 11 lines scroll is performed.

    Input:

    d

    Output:

    option d for bzmore

  • i(space) : It displays i more lines on the terminal. If no i is given, it shows another screenful scroll. Here, i is an integer argument, defaulting to 1.

    Input:

    4(space)

    Output:

    option i(space) for bzmore

  • iz : This option displays i more lines same as i(space) and the scroll is now set to i.

    Input:

    5z

    Output:

    option iz for bzmore

  • is : It skips i number of lines and prints the lines according to the previously saved i. If no i is given, it then print screenful of lines.

    Input:

    2s

    Output:

    option is for bzmore

    Note: The previously saved i in option3 was 5, so this options skipped 2 lines as commanded and then a 5 line scroll is printed.

  • if : This option skips whole i screenfuls and print a screenful of lines. If i is already saved using previous commands, this command skips i(previous) * i(present) lines and print a screenful of lines.

    Example 1: In this example, no i is previously saved.

    Input:.

    1f

    Output:

    option if with no i saved for bzmore

    Example 2: In this example, i=2 is saved previously using the command 2z.

    Input:

    2f

    Output:
    option if with i saved for bzmore

    Note: 4 ( 2*2 ) lines are skipped on the terminal and 2 lines are printed because of the previously saved i=2.

  • q : This command lets quit the reading of the current file.

    Input:

    q

    Output:

    option q for bzmore

  • = (equals): It shows the current line number on the terminal.

    Input:

    =

    Output:
    option =(equals) for bzmore

  • . (dot) : This command repeats the previously entered command.

    Input:

    .

    Output:

    option (dot) for bzmore

    Note: The previously entered command was 2(space), so two lines are printed and then by using .(dot) command previously entered command is repeated.

  • –help: It displays help information.

    Syntax :

    $ bzmore --help

    Output:

    option -help for bzmore

  • –version: It displays version information.

    Syntax:

    $ bzmore --version

    Output:

    option -version for bzmore



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.