Less (Unix)

Short description: Terminal pager

less

`less` output in an x-terminal

Developer(s)| Mark Nudelman
Initial release| 1984; 42 years ago (1984)[1]
Stable release|

643[2] / 12 August 2023; 2 years ago (2023-08-12)

Repository| github.com/gwsw/less
Written in| C
Operating system| Cross-platform
Type| System utility
License| Dual-licensed under GNU GPLv3 and a custom BSD-style license
Website| www.greenwoodsoftware.com/less/

`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 more, but has the extended capability of allowing both forward and backward navigation through the file. Unlike most Unix text editors/viewers, less does not need to read the entire file before starting, allowing for immediate viewing regardless of file size.

## Contents

* 1 History
* 2 Usage
* 2.1 Frequently used options
* 2.2 Frequently used commands
* 3 Examples
* 4 Memory considerations
* 5 See also
* 6 References
* 7 External links

## History

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.[3] It is still maintained today by Nudelman.

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

## Usage

less 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 less is displaying the file, various commands can be used to navigate through the file. These commands are based on those used by both more and vi. It is also possible to search for character patterns in the file.

By default, less 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, less behaves like cat.

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.[4][5]

The command-syntax is:

less [options] [file_name]...

### Frequently used options

* `-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 commands

Key  | Command

|

| Next Page
| Next half Page
| Previous Page
| Previous half Page
| Edit Content
or | Next Line
| Previous Line
| Top of file
| End of file
| Follow Mode (for expanding logs or pipes). Interrupt (or from v581 [6]) to abort.
or | First Line
or | Last Line
`⟨n⟩` | Line `⟨n⟩`
`⟨text⟩` | Forward Search for `⟨text⟩`. Text is interpreted as a regex.
`⟨text⟩` | Backward Search like
`⟨text⟩` | grep like filter
| Next Search Match
| Previous Search Match
| Turn off Match Highlighting (see `-g` command line option)
`⟨c⟩` | Toggle option `⟨c⟩`, e.g., toggles option to match case in searches
`⟨c⟩` | Set Mark `⟨c⟩`
`⟨c⟩` | Go to Mark `⟨c⟩`
or | File information
| Next file
| Previous file
| Help. This is presented with `less`, to quit.
| Quit

## Examples

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

## Memory considerations

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. For this reason, some companies/organisations insist that less be used only with fixed buffering - or not at all - on production machines. [citation needed]

## See also

* more (command)
* most (Unix)
* pg (Unix)

## References

1. ↑ "less, a paginator". https://groups.google.com/d/msg/net.sources/GikfOBWCl0s/agdI4hW2ix8J.
2. ↑ "less home page". https://www.greenwoodsoftware.com/less/.
3. ↑ "Less FAQ". https://www.greenwoodsoftware.com/less/faq.html#unix.
4. ↑ "lesspipe(1) — less — Debian bullseye — Debian Manpages". https://manpages.debian.org/bullseye/less/lesspipe.1.en.html.
5. ↑ "lesspipe(1) — Arch manual pages". https://man.archlinux.org/man/lesspipe.1.
6. ↑ "Less version 581". Greenwood Software. 7 April 2021. http://www.greenwoodsoftware.com/less/news.581.html.

## External links

* Manual page on freebsd.org
* Manual page on man7.org
* Entry in Free Software Directory

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* sed
* sort
* strings
* tail
* tr
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Less (Unix). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Less_(Unix)&oldid=458129"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template