Less

From LQWiki
Jump to: navigation, search

less is the name of a popular and common pager. As such, it facilitates browsing through large amounts of text. At one time, more was the canonical pager; less was developed as a more powerful alternative. It is ironically named, because "less is more". Both tools are usually included in modern Linux distributions.

Many commands produce reams of output, often scrolling by too quickly to be readable. Also, many text files are larger than the physical screen or current terminal window. The intent of a pager is to let the user browse such text at his own pace.

How to use it

You can use it to view files:

less myfile.txt

And to view output, e.g. to stdout:

ls | less

Quit less with the key q.

Comparing less and more

The original more only let you advance to the next page, and the standard current more only allows backwards scrolling through files on disk and not through pipes. One of less's advantages is that it buffers the text as much as possible, letting you scroll backward or forward through files or piped data. In either program, you can search for patterns in the text, or even edit it using your favorite editor.

External links