Template:Short description Template:Lowercase title {{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1 | unknown = Template:Main other | preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y | AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid }}Template:Main other less is a terminal pager program on Unix, Windows, and Unix-like systems used to view (but not change) the contents of a text file one screen at a time. It is similar to Template:Mono, but has the extended capability of allowing both forward and backward navigation through the file. Unlike most Unix text editors/viewers, Template:Mono does not need to read the entire file before starting, allowing for immediate viewing regardless of file size.

HistoryEdit

Mark Nudelman initially wrote less during 1983–85, in the need of a version of more able to do backward scrolling of the displayed text. The name came from the joke of doing "backwards more." Originally, less was developed for Unix, but it has been ported to a number of other operating systems, including MS-DOS, Microsoft Windows, OS/2, and OS-9, as well as Unix-like systems such as Linux.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> It is still maintained today by Nudelman.

To help remember the difference between less and more, a common joke is to say, "Template:Mono," implying that less has greater functionality than Template:Mono. A similar saying is that "less is more, more or less".

UsageEdit

Template:Mono can be invoked with options to change its behaviour, for example, the number of lines to display on the screen. A few options vary depending on the operating system. While Template:Mono is displaying the file, various commands can be used to navigate through the file. These commands are based on those used by both Template:Mono and Template:Mono. It is also possible to search for character patterns in the file.

By default, Template:Mono displays the contents of the file to the standard output (one screen at a time). If the file name argument is omitted, it displays the contents from standard input (usually the output of another command through a pipe). If the output is redirected to anything other than a terminal, for example a pipe to another command, Template:Mono behaves like Template:Mono.

The "lesspipe" extension can automatically determine file types such as PDF, multimedia, and compressed archives, and automatically determines which program to launch display the file's information with, such as text from a PDF file, metadata of photos, lists of files in a compressed archive, and content of a single file in a compressed archive.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

The command-syntax is:

less [options] [file_name]...

Frequently used optionsEdit

  • -g: Highlight just the current match of any searched string.
  • -i: Search case-insensitively.
  • -m: Show more detailed prompt, including file position.
  • -N: Show line numbers (useful for viewing source code).
  • -x3: Set tabstops (the number of columns per hard tab character) to the specified number (3, in this example) (useful for viewing source code).
  • -S: Disable line wrapping ("chop long lines"). Long lines can be seen by side-scrolling.
  • -X: Leave file contents on screen when less exits.
  • -?: Show help.
  • --follow-name: Follow mode, for log files that get replaced while being viewed.

Frequently used commandsEdit

Key Command
Template:Key press Next Page
Template:Key press Next half Page
Template:Key press Previous Page
Template:Key press Previous half Page
Template:Key press Edit Content
Template:Key press or Template:Key press Next Line
Template:Key press Previous Line
Template:Key press Top of file
Template:Key press End of file
Template:Key press Follow Mode (for expanding logs or pipes). Interrupt (or from v581 Template:Key press<ref>{{#invoke:citation/CS1|citation CitationClass=web

}}</ref>) to abort.

Template:Key press or Template:Key press First Line
Template:Key press or Template:Key press Last Line
Template:AngbrTemplate:Key press Line Template:Angbr
Template:Key pressTemplate:Angbr Forward Search for Template:Angbr. Text is interpreted as a regex.
Template:Key pressTemplate:Angbr Backward Search like Template:Key press
Template:Key pressTemplate:Angbr grep like filter
Template:Key press Next Search Match
Template:Key press Previous Search Match
Template:Key pressTemplate:Key press Turn off Match Highlighting (see -g command line option)
Template:Key pressTemplate:Angbr Toggle option Template:Angbr, e.g., Template:Key pressTemplate:Key press toggles option to match case in searches
Template:Key pressTemplate:Angbr Set Mark Template:Angbr
Template:Key pressTemplate:Angbr Go to Mark Template:Angbr
Template:Key press or Template:Key press File information
Template:Key pressTemplate:Key press Next file
Template:Key pressTemplate:Key press Previous file
Template:Key press Help. This is presented with less, Template:Key press to quit.
Template:Key press Quit

ExamplesEdit

<syntaxhighlight lang="bash"> less -M readme.txt # Read "readme.txt" less +F /var/log/mail.log # Follow mode for log file * | less # Easier file analysis less -I -p void *.c # Case insensitive search for "void" in all .c files </syntaxhighlight>

Memory considerationsEdit

The --buffers=n and --auto-buffers options control how much memory less may use to buffer inputs. This is most relevant when less is directly accessing a named file that is modified or deleted while less is still running, and when less is receiving data from a pipe and the data can not be randomly accessed or regenerated. On the other hand, unlimited buffering means that less will request as much memory as it is fed data, which could drive the system into using virtual memory and swapping a lot of data between RAM and disks (dramatically slowing system performance for most applications on the host), or even further into memory exhaustion where any application on the host requesting memory may have that request denied, or may crash when attempting to access memory that the OS promised but can't find when the application actually attempts to use it and a page-fault occurs. Template:Citation needed

See alsoEdit

ReferencesEdit

Template:Reflist

External linksEdit

Template:Unix commands