Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Less (Unix)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Terminal pager}} {{lowercase title}} {{Infobox software | name = less | logo = | screenshot = Less.PNG | caption = <code>less</code> output in an [[xterm|x-terminal]] | developer = Mark Nudelman | released = {{Start date and age|1984}}<ref>{{cite web | url = https://groups.google.com/d/msg/net.sources/GikfOBWCl0s/agdI4hW2ix8J | title = less, a paginator | archive-url = https://web.archive.org/web/20230207045624/https://groups.google.com/g/net.sources/c/GikfOBWCl0s/m/agdI4hW2ix8J | archive-date = February 7, 2023 }}</ref> | latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}} | latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}} | repo = {{URL|https://github.com/gwsw/less}} | programming language = [[C (programming language)|C]] | operating system = [[Cross-platform]] | genre = [[System utility]] | license = [[Multi-licensing|Dual-licensed]] under [[GNU Project|GNU]] [[GNU General Public License#Version 3|GPLv3]] and a custom [[BSD licenses#2-clause|BSD-style]] license | website = {{URL|https://www.greenwoodsoftware.com/less/}} }} '''<code>less</code>''' is a [[terminal pager]] [[Computer program|program]] on [[Unix]], [[Microsoft Windows|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 {{mono|[[more (command)|more]]}}, but has the extended capability of allowing both forward and backward navigation through the file. Unlike most Unix text editors/viewers, {{mono|less}} does not need to read the entire file before starting, allowing for immediate viewing regardless of file size. ==History== [[Mark Nudelman]] initially wrote <code>less</code> during 1983β85, in the need of a version of <code>[[More (command)|more]]</code> able to do backward scrolling of the displayed text. The name came from the joke of doing "backwards more." Originally, <code>less</code> 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>{{cite web |url=https://www.greenwoodsoftware.com/less/faq.html#unix |title = Less FAQ}}</ref> It is still maintained today by Nudelman. To help remember the difference between <code>less</code> and <code>more</code>, a common joke is to say, "{{mono|less > more}}," implying that <code>less</code> has greater functionality than {{mono|more}}. A similar saying is that "<code>less</code> is <code>more</code>, more or less". ==Usage== {{mono|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 {{mono|less}} is displaying the file, various commands can be used to navigate through the file. These commands are based on those used by both {{mono|more}} and {{mono|[[Vi (text editor)|vi]]}}. It is also possible to search for character patterns in the file. By default, {{mono|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 [[Pipeline (Unix)|pipe]]). If the output is redirected to anything other than a [[Computer terminal|terminal]], for example a pipe to another command, {{mono|less}} behaves like {{mono|[[cat (Unix)|cat]]}}. The "lesspipe" extension can automatically determine file types such as [[PDF]], multimedia, and [[compressed archive]]s, 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>{{cite web |url=https://manpages.debian.org/bullseye/less/lesspipe.1.en.html |title = lesspipe(1) β less β Debian bullseye β Debian Manpages}}</ref><ref>{{cite web |url=https://man.archlinux.org/man/lesspipe.1 |title = lesspipe(1) β Arch manual pages}}</ref> The command-[[syntax]] is: less [options] [file_name]... ===Frequently used options=== *<code>-g</code>: Highlight just the current match of any searched string. *<code>-i</code>: Search case-insensitively. *<code>-m</code>: Show more detailed prompt, including file position. *<code>-N</code>: Show line numbers (useful for viewing [[source code]]). *<code>-x3</code>: Set tabstops (the number of columns per hard tab character) to the specified number (3, in this example) (useful for viewing [[source code]]). *<code>-S</code>: Disable line wrapping ("chop long lines"). Long lines can be seen by side-scrolling. *<code>-X</code>: Leave file contents on screen when less exits. *<code>-?</code>: Show help. *<code>--follow-name</code>: Follow mode, for log files that get replaced while being viewed. ===Frequently used commands=== {| class="wikitable" border="1" |- ! Key ! Command |- ! {{Key press|Space bar}} | Next Page |- ! {{Key press|d}} | Next half Page |- ! {{Key press|b}} | Previous Page |- ! {{Key press|u}} | Previous half Page |- ! {{Key press|v}} | Edit Content |- ! {{Key press|j}} <span style="font-weight: normal;">or</span> {{Key press|Enter}} | Next Line |- ! {{Key press|k}} | Previous Line |- ! {{Key press|Home}} | Top of file |- ! {{Key press|End}} | End of file |- ! {{Key press|F}} | Follow Mode (for expanding logs or pipes). Interrupt (or from v581 {{Key press|Ctrl|X}}<ref>{{cite web|url=http://www.greenwoodsoftware.com/less/news.581.html|title=Less version 581|publisher=Greenwood Software|date=7 April 2021|access-date=31 July 2023}}</ref>) to abort. |- ! {{Key press|g}} <span style="font-weight: normal;">or</span> {{Key press|<}} | First Line |- ! {{Key press|G}} <span style="font-weight: normal;">or</span> {{Key press|>}} | Last Line |- ! <code>{{angbr|n}}</code>{{Key press|G}} | Line <code>{{angbr|n}}</code> |- ! {{Key press|/}}<code>{{angbr|text}}</code> | Forward Search for <code>{{angbr|text}}</code>. Text is interpreted as a [[Regular expression|regex]]. |- ! {{Key press|?}}<code>{{angbr|text}}</code> | Backward Search like {{Key press|/}} |- ! {{Key press|&}}<code>{{angbr|text}}</code> | [[grep]] like filter |- ! {{Key press|n}} | Next Search Match |- ! {{Key press|N}} | Previous Search Match |- ! {{Key press|Esc}}{{Key press|u}} | Turn off Match Highlighting (see <code>-g</code> command line option) |- ! {{Key press|-}}<code>{{angbr|c}}</code> | Toggle option <code>{{angbr|c}}</code>, e.g., {{Key press|-}}{{Key press|i}} toggles option to match case in searches |- ! {{Key press|m}}<code>{{angbr|c}}</code> | Set Mark <code>{{angbr|c}}</code> |- ! {{Key press|'}}<code>{{angbr|c}}</code> | Go to Mark <code>{{angbr|c}}</code> |- ! {{Key press|{{=}}}} <span style="font-weight: normal;">or</span> {{Key press|Ctrl|G}} | File information |- ! {{Key press|:}}{{Key press|n}} | Next file |- ! {{Key press|:}}{{Key press|p}} | Previous file |- ! {{Key press|h}} | Help. This is presented with <code>less</code>, {{Key press|q}} to quit. |- ! {{Key press|q}} | Quit |} ==Examples== <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 considerations== The <code>--buffers=n</code> and <code>--auto-buffers</code> 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. {{Citation needed|date=October 2011}} ==See also== * [[more (command)]] * [[most (Unix)]] * [[pg (Unix)]] ==References== {{Reflist}} ==External links== * [http://www.freebsd.org/cgi/man.cgi?query=less&apropos=0&sektion=0&arch=default&format=html Manual page on freebsd.org] * [https://man7.org/linux/man-pages/man1/less.1.html Manual page on man7.org] * [https://directory.fsf.org/wiki/Less Entry in Free Software Directory] {{Unix commands}} [[Category:GNU Project software]] [[Category:Terminal pagers]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Angbr
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite web
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Key press
(
edit
)
Template:Lowercase title
(
edit
)
Template:Main other
(
edit
)
Template:Mono
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Template other
(
edit
)
Template:Unix commands
(
edit
)