The LESS Home Page


Welcome to the less home page!

This is the official home page for information about the pager less. Less was written by Mark Nudelman (marknu@flash.net).


News

less-340 was released on 27 Apr 1999.

You can download a copy of less from here.

This page was last updated on 5 Jun 1999.

This page has been viewed 3086 times since 4 April 1999.


Frequently Asked Questions about less

Table of Contents

  1. Overview
    1. What is less?
    2. Why would I want to use less?
    3. Where did less come from?
  2. Resources
    1. How can I get a copy of less?
    2. When is the next version of less going to be released?
    3. How can I write to the author of less?
  3. Technical questions
    1. Is less Y2K compliant?
    2. Cool less tricks
    3. I can't get less to build!
    4. Do I need Unix to use less?
    5. Can less display non-English language characters?
    6. Why does less scroll off the screen if there are long lines?
    7. Why does -r cause display problems?
    8. Can less leave the screen alone when it quits?
    9. Why doesn't less quit when it reaches the end of the file?
    10. Why does it take so long to start the editor / start a shell?
    11. Why does it say "stty: TCGETS: Operation not supported on socket"?
    12. Can less view compressed files?
    13. Why are there no dots in the version number?
    14. What if I find a bug in less?
This FAQ is Copyright ©1999 by Mark Nudelman. This document may be reproduced, so long as it is kept in its entirety and in its original format.

Questions and Answers

What is less?

Less is a pager. A pager is a program that displays text files. Other pagers commonly in use are more and pg. Pagers are often used in command-line oriented systems like Unix and MS-DOS to display files. Windowing systems like Windows and the Macintosh don't need pagers as much, since they have other methods for viewing files.

Less is not an editor. You can't change the contents of the file you're viewing. Less is not a windowing system. It doesn't have fancy scroll bars or other GUI (graphical user interface) elements. It was designed to work on simple text-only terminals.

Less has been used by thousands of people around the world since its release in 1985.

Why would I want to use less?

If you're not using a pager now, then you probably don't need less. But if you're using another pager, you should take a look at less. Less has some very nice features:

Backwards movement
It's hard to believe some people are still using pagers that don't let you move backwards in the file. Even pagers that do let you move backwards often don't work when viewing "standard input"; that is, data that is being piped into the pager from another program.
Searching and highlighting
Less lets you search for text in the file you're viewing. You can search forwards and backwards. Furthermore, less highlights the text that matches your search, to make it easy to see where the match is.
Multiple files
Less allows you to switch between any number of different files, remembering your position in each file. You can also do a single search which spans all the files you are working with.
Bold and underline
Some text files, notably Unix-style "man pages", use overstriking (backspaces) to simulate underlined and bold text. Less interprets this overstriking and displays the text in real underlined or bold mode.
Advanced features
Less has a large number of fancy features for advanced users. Once you learn the basics, you'll find you can customize less to do almost anything you want it to do. You can change key bindings, set different tab stops, set up filters to view compressed data or other file types, customize the prompt, display line numbers, use "tag" files, and more.
Portability
Less is available on many different machines, different system architectures, and different terminals. Pretty much wherever you go, you'll find less. You won't have to learn how to use a different pager on every system you use.

Where did less come from?

Back in 1983, I was working for a now-defunct company called Integrated Office Systems. Some of our software ran on a Unix system and produced enormous log files of its transactions. We wanted to be able to search these log files for error messages. But the version of "vi" we were using couldn't handle files larger than a certain size, and our log files often exceeded that size. So we were forced to use "more" to view the files. The problem was, once we found an error message, what we really wanted to see was the transactions leading up to the error; that is, the lines in the log file immediately before the error message. But more didn't allow backward movement in the file.

We often complained about this problem. We said we needed a "backwards more"; someone (it wasn't me, but unfortunately I don't remember who it was) coined the name "less" as a joke on the concept of a "backwards more". It didn't seem to me that it would be too difficult to write a simple pager that would allow forward and backward movement. I wrote the first version in late 1983 and we began using it internally. I continued to enhance it and finally decided it was a useful enough tool that I should make it available to the world. I posted the first version to the newsgroup called (at that time) net.sources in May, 1985.

Making the program publicly available allowed an enormous number of people to use it. Many people have made their own modifications and donated them to me for incorporation into the official version, and many more have reported bugs they've found or made suggestions about features they'd like to see added. This was my first experience with the concept of what is now called "open source" or "free software", and it has, I believe, produced a very high quality product. I'd like to thank all the users of less for their invaluable comments and suggestions over the years. Less wouldn't be what it is today without you.

How can I get a copy of less?

You can download a copy of less from here.

Less is also distributed as a part of the standard software available with many varieties of Unix and similar systems. Less is also available from many ftp sites, including the GNU archives on ftp.gnu.org/gnu/less.

When is the next version of less going to be released?

Version 335 was released on 3 Apr 1999 and version 340 was released on 27 Apr 1999. Any bugs found in this version will be fixed as soon as possible. There are as yet no plans for another release.

How can I write to the author of less?

Less was written by Mark Nudelman and is currently being maintained by him. You can write to him at marknu@flash.net.

Is less Y2K compliant?

Neither less nor lesskey use dates in any way, so there should be no Y2K issues with either program. However, no extensive testing has been done to verify this.

There are some ways that Y2K problems in other programs could affect the operation of less. For example, Unix versions of less use the shell to perform file name expansion. So if the shell you are using has Y2K bugs, it could cause less to fail to expand filenames correctly. Similarly, if you are using a LESSOPEN program which has Y2K bugs, it could affect the operation of less.

Cool less tricks

New users of less sometimes find that less doesn't behave exactly the way they expect. If this is the case, don't despair. Less has an enormous number of options (perhaps too many) which let you change the way it behaves. Chances are, there is a way to make less do what you want. A complete description of all these features is in the less man page, but here's a summary of some of the more popular ones.

Quit at end-of-file
To make less automatically quit as soon as it reaches the end of the file (so you don't have to hit "q"), set the -E option.
Verbose prompt
To see a more verbose prompt, set the -m or -M option. You can also design your own prompt; see the man page for details.
Clear the whole screen
To make less clear and repaint the screen rather than scrolling when you move to a new page of text, set the -C option.
Case-less searches
To treat upper-case and lower-case letters the same in searches, set the -I option.
Start at a specific place in the file
To start at a specific line number, say line 150, use "less +150 filename". To start where a specific pattern first appears, use "less +/pattern filename". To start at the end of the file, use "less +G filename".
Scan all instances of a pattern in a set of files
To search multiple files, use "/*pattern" instead of just "/pattern". To do this from the command line, use "less '+/*pattern' ...". Note that you may need to quote the "+/*pattern" argument to prevent your shell from interpreting the "*".
Watch a growing file
Use the F command to go to the end of the file and keep displaying more text as the file grows. You can do this from the command line by using "less +F ...".
Change keys
The lesskey program lets you change the meaning of any key or sequence of keys. See the lesskey man page for details.
Save your favorite options
If you want certain options to be in effect whenever you run less, without needing to type them in every time, just set your "LESS" environment variable to the options you want. (If you don't know how to set an environment variable, consult the documentation for your system or your shell.) For example, if your LESS environment variable is set to "-IE", every time you run less it will do case-less searches and quit at end-of-file.

I can't get less to build!

There are a number of possible reasons why less may not be building on your system. If you're building on a Unix system, and you ran "sh configure" once, you might try removing the "config.log" and "config.cache" files and trying it all from scratch again; that is, run "sh configure" again.

If that doesn't help and you're still stumped, send email to the author describing your problem. If possible, include the messages produced by the configure and/or make procedures.

Do I need Unix to use less?

Less was originally developed for Unix, but has been ported to a variety of other systems, including MS-DOS, Windows, OS/2, and OS-9. See the download page for a list of supported systems.

Can less display non-English language characters?

Less can display non-English characters as long as each character is one byte long. To use a non-ASCII single-byte character set, you need to set up your system with the correct "locale" settings. If your system does not support setlocale, you can set the LESSCHARSET or LESSCHARDEF environment variable to tell less what language you are using. See the section "NATIONAL CHARACTER SETS" in the man page for details.

The standard version of less doesn't work for languages such as Japanese and Chinese, which require more than one byte per character. There is a modified version called "cless" which is supposed to work with Chinese, but I haven't used it and I'm not sure where to get the latest version. There are also several versions modified to work with Japanese, but again, I haven't used them. One such Japanese version is available as a patch to less-330, at http://www.io.com/~kazushi/less.

Why does less scroll off the screen if there are long lines?

If you see data scroll off the screen when you view lines longer than the screen width, something is wrong. There are two likely possibilities. First, you may be using the -r option (either explicitly or in your LESS environment variable). The man page states that the -r option may cause display problems (see Why does -r cause display problems? for more details). The other possibility is more difficult to diagnose: you may have a mismatch between your termcap setup and the type of your terminal. On most systems, you should check that:

Why does -r cause display problems?

Less needs to keep track of where the cursor is on the screen as it displays text, so that it knows when it reaches the end of the line. If the screen is 24 lines high, less wants to display enough text to exactly fill those 24 lines. To do this, it needs to know when it reaches the end of a line on the screen. But if it just starts outputting raw control characters (like ESC), it won't be able to keep track of this. For example, if less outputs four ordinary characters, it moves the cursor four spaces to the right. But on a vt220 terminal, if less outputs the four characters "ESC [ 1 m", it merely switches the terminal to "bold", but doesn't move the cursor. On the other hand, if it outputs "ESC [ 1 H", it moves the cursor to the top left corner of the screen! Obviously less would need to know what every escape sequence does to the particular terminal being used, which is not practical. So by default less does not output ESC or other control characters, to avoid this problem. When -r is set, it does output control characters, but then it is no longer possible to determine when the text wraps to a new line on the display, so the display may not be accurate in all cases.

Can less leave the screen alone when it quits?

When less quits, it sends the "te" termcap string to the terminal. Exactly what that does depends on the system you are using, the type of terminal, and your version of termcap. On some systems, it does nothing; on others it restores the screen to the state it was in when less started, thus erasing from the screen the last page of the file which less was viewing. If you don't like the behavior of "te" on your system, you can disable the sending of the "te" string by invoking less with the -X option. If you want "te" to do something different (for example, restore the screen if it's not doing that already), you'll have to figure out how to override the default termcap on your system. Unfortunately, this is done differently on different systems, so you'll have to check the documentation for your system.

Why doesn't less quit when it reaches the end of the file?

Normally, less doesn't quit until you type "q". You can make it quit as soon as it reaches the end of the file by using the -E option. However, many (but not all) people prefer to have less remain active until they explicitly quit, because they might wish to back up and look at earlier parts of the file again.

Why does it take so long to start the editor / start a shell?

If you use csh, you may find it takes a long time to start a shell (using the "!" command) or to start an editor (using the "v" command). This is usually because your .cshrc file contains many commands. Csh executes the commands in .cshrc each time less starts a subshell. If you only need these commands executed once at login, and not in every subshell, you can move them to .login instead of .cshrc. Changing your SHELL environment variable to "sh" can also avoid this problem, although you will then be using sh rather than csh in programs that use the SHELL variable. You can also try setting SHELL to "csh -f", which tells csh not to execute the .cshrc or .login files.

Why does it say "stty: TCGETS: Operation not supported on socket"?

If you see this message and you're using csh, you probably have a "stty" command in your .cshrc file. You should either move this to your .login file so it only gets executed once, when you login; or set your SHELL variable to "csh -f", which tells csh not to execute the .cshrc or .login files.

Can less view compressed files?

Less provides a mechanism to preprocess the file being viewed. The preprocessing can decompress a compressed file, or do other arbitrary processing on the file contents. However, each user must specify their own preprocessor. See the INPUT PREPROCESSOR section of the man page for more details. Less does not provide any default preprocessing, because the types of compressed files likely to be viewed depends on the work habits of the particular user. In a future release of less, some automatic preprocessing may be provided.

Why are there no dots in the version number?

I use a very simple version numbering scheme. The first version of less was version 1. The next was version 2. And so on. There are no "major" and "minor" releases, so there are no dots in the version number. So version 340 is the three hundred and fortieth version of less. It's just 340, not 3.40 or 3.4.0.

What if I find a bug in less?

If you find a bug in less, please send email to the author. Describe the bug in as much detail as possible, and I'll do what I can to help resolve the problem.