One of the most commonly used programs in a Unix system is the pager less. It is inspired by more and has much greater functionality. Since it may be so simply used, reading its documentation is not necessary and many of its advanced features are not used. The aim of this post is to describe what I found reading its man page.
I use less when I do not need to edit a file or I need to view output of other program. It does not load the whole file, so it can be useful even with a dump of a whole hard disk (I used it in times of 20 GB disks). Typical text editors have problems with files of several hundred megabytes.
The most popularized feature of less is backward movement in a file. It can be easily seen that less supports arrow keys for movement in a file, but it supports also many vi-like key sequences. Of them I usually use only ng to move to nth line (Xdvi uses the same key sequence to move to nth page), / for searching with regular expressions and q to quit less.
Rarely I use less to view more than one file. The command :e allows opening a new file (giving many files on the command line is also useful, especially with shell wildcards). The files may be switched with :n and :p, meaning next and previous, respectively; and :x shows the first file. These commands also accept a number before : to use nth file instead of first in the given direction. To close a file, use :d.
Another useful feature in less is support for input processors. For example, in Gentoo GNU/Linux by default less uncompresses files in many formats, converts PDFs to text, views files in archives, etc. In Debian just enable it in the .bashrc file.
