Linux "pager" Command Line Options and Examples
opposite of more

Less is a program similar to more (1), but it has many more features. Less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi (1). Less uses termcap (or terminfo on some systems), so it can run on a variety of terminals.


Usage:

less -?
less --help
less -V
less --version
less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
[-# shift] [+[+]cmd] [--] [filename]...
(See the OPTIONS section for alternate option syntax with long option names.)






Command Line Options:

--quiet
begin with --qui. Some long option names are in uppercase, such as --QUIT-AT-EOF, as distinct from
pager --quiet ...
-?
This option displays a summary of the commands accepted by less (the same as the h command). (Depend‐ing on how your shell interprets the question mark, it may be necessary to quote the question mark,thus: "-\?".)
pager -? ...
-a
By default, forward searches start at the top of the displayed screen and backwards searches start atthe bottom of the displayed screen (except for repeated searches invoked by the n or N commands, whichstart after or before the "target" line respectively; see the -j option for more about the targetline). The -a option causes forward searches to instead start at the bottom of the screen and backwardsearches to start at the top of the screen, thus skipping all lines displayed on the screen.
pager -a ...
-A
Causes all forward searches (not just non-repeated searches) to start just after the target line, andall backward searches to start just before the target line. Thus, forward searches will skip part ofthe displayed screen (from the first line up to and including the target line). Similarly backwardssearches will skip the displayed screen from the last line up to and including the target line. Thiswas the default behavior in less versions prior to 441.
pager -A ...
-bn
Specifies the amount of buffer space less will use for each file, in units of kilobytes (1024 bytes).By default 64 K of buffer space is used for each file (unless the file is a pipe; see the -B option).The -b option specifies instead that n kilobytes of buffer space should be used for each file. If n is
pager -bn ...
-1
buffer space is unlimited; that is the entire file can be read into memory.
pager -1 ...
-B
By default, when data is read from a pipe, buffers are allocated automatically as needed. If a largeamount of data is read from the pipe, this can cause a large amount of memory to be allocated. The -Boption disables this automatic allocation of buffers for pipes, so that only 64 K (or the amount ofspace specified by the -b option) is used for the pipe. Warning: use of -B can result in erroneousdisplay, since only the most recently viewed part of the piped data is kept in memory; any earlier datais lost.
pager -B ...
-c
Causes full screen repaints to be painted from the top line down. By default, full screen repaints aredone by scrolling from the bottom of the screen.
pager -c ...
-C
Same as -c, for compatibility with older versions of less.
pager -C ...
-d
The -d option suppresses the error message normally displayed if the terminal is dumb; that is, lackssome important capability, such as the ability to clear the screen or scroll backward. The -d optiondoes not otherwise change the behavior of less on a dumb terminal.
pager -d ...
-Dxcolor
[MS-DOS only] Sets the color of the text displayed. x is a single character which selects the type oftext whose color is being set: n=normal, s=standout, d=bold, u=underlined, k=blink. color is a pair ofnumbers separated by a period. The first number selects the foreground color and the second selectsthe background color of the text. A single number N is the same as N.M, where M is the normal back‐ground color. x may also be a to toggle strict ANSI sequence rendering (SGR mode).
pager -Dxcolor ...
-e
Causes less to automatically exit the second time it reaches end-of-file. By default, the only way toexit less is via the "q" command.
pager -e ...
-E
Causes less to automatically exit the first time it reaches end-of-file.
pager -E ...
-f
Forces non-regular files to be opened. (A non-regular file is a directory or a device special file.)Also suppresses the warning message when a binary file is opened. By default, less will refuse to opennon-regular files. Note that some operating systems will not allow directories to be read, even if -fis set.
pager -f ...
-F
Causes less to automatically exit if the entire file can be displayed on the first screen.
pager -F ...
-g
Normally, less will highlight ALL strings which match the last search command. The -g option changesthis behavior to highlight only the particular string which was found by the last search command. Thiscan cause less to run somewhat faster than the default.
pager -g ...
-G
The -G option suppresses all highlighting of strings found by search commands.
pager -G ...
-hn
Specifies a maximum number of lines to scroll backward. If it is necessary to scroll backward morethan n lines, the screen is repainted in a forward direction instead. (If the terminal does not havethe ability to scroll backward, -h0 is implied.)
pager -hn ...
-i
Causes searches to ignore case; that is, uppercase and lowercase are considered identical. This optionis ignored if any uppercase letters appear in the search pattern; in other words, if a pattern containsuppercase letters, then that search does not ignore case.
pager -i ...
-I
Like -i, but searches ignore case even if the pattern contains uppercase letters.
pager -I ...
-jn
Specifies a line on the screen where the "target" line is to be positioned. The target line is theline specified by any command to search for a pattern, jump to a line number, jump to a file percentageor jump to a tag. The screen line may be specified by a number: the top line on the screen is 1, thenext is 2, and so on. The number may be negative to specify a line relative to the bottom of thescreen: the bottom line on the screen is -1, the second to the bottom is -2, and so on. Alternately,the screen line may be specified as a fraction of the height of the screen, starting with a decimalpoint: .5 is in the middle of the screen, .3 is three tenths down from the first line, and so on. Ifthe line is specified as a fraction, the actual line number is recalculated if the terminal window isresized, so that the target line remains at the specified fraction of the screen height. If any formof the -j option is used, repeated forward searches (invoked with "n" or "N") begin at the line immedi‐ately after the target line, and repeated backward searches begin at the target line, unless changed by
pager -jn ...
-J
Displays a status column at the left edge of the screen. The status column shows the lines thatmatched the current search. The status column is also used if the -w or -W option is in effect.
pager -J ...
-kfilename
Causes less to open and interpret the named file as a lesskey (1) file. Multiple -k options may bespecified. If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or if a lesskey file is foundin a standard place (see KEY BINDINGS), it is also used as a lesskey file.
pager -kfilename ...
-K
Causes less to exit immediately (with status 2) when an interrupt character (usually ^C) is typed.Normally, an interrupt character causes less to stop whatever it is doing and return to its commandprompt. Note that use of this option makes it impossible to return to the command prompt from the "F"command.
pager -K ...
-L
Ignore the LESSOPEN environment variable (see the INPUT PREPROCESSOR section below). This option canbe set from within less, but it will apply only to files opened subsequently, not to the file which iscurrently open.
pager -L ...
-m
Causes less to prompt verbosely (like more), with the percent into the file. By default, less promptswith a colon.
pager -m ...
-M
Causes less to prompt even more verbosely than more.
pager -M ...
-n
Suppresses line numbers. The default (to use line numbers) may cause less to run more slowly in somecases, especially with a very large input file. Suppressing line numbers with the -n option will avoidthis problem. Using line numbers means: the line number will be displayed in the verbose prompt and inthe = command, and the v command will pass the current line number to the editor (see also the discus‐sion of LESSEDIT in PROMPTS below).
pager -n ...
-N
Causes a line number to be displayed at the beginning of each line in the display.
pager -N ...
-ofilename
Causes less to copy its input to the named file as it is being viewed. This applies only when theinput file is a pipe, not an ordinary file. If the file already exists, less will ask for confirmationbefore overwriting it.
pager -ofilename ...
-Ofilename
The -O option is like -o, but it will overwrite an existing file without asking for confirmation.If no log file has been specified, the -o and -O options can be used from within less to specify a logfile. Without a file name, they will simply report the name of the log file. The "s" command isequivalent to specifying -o from within less.
pager -Ofilename ...
-ppattern
The -p option on the command line is equivalent to specifying +/pattern; that is, it tells less tostart at the first occurrence of pattern in the file.
pager -ppattern ...
-Pprompt
Provides a way to tailor the three prompt styles to your own preference. This option would normally beput in the LESS environment variable, rather than being typed in with each less command. Such anoption must either be the last option in the LESS variable, or be terminated by a dollar sign.
pager -Pprompt ...
-Ps
followed by a string changes the default (short) prompt to that string.
pager -Ps ...
-Pm
changes the medium (-m) prompt.
pager -Pm ...
-PM
changes the long (-M) prompt.
pager -PM ...
-Ph
changes the prompt for the help screen.
pager -Ph ...
-P
changes the message printed by the = command.
pager -P ...
-q
Causes moderately "quiet" operation: the terminal bell is not rung if an attempt is made to scroll pastthe end of the file or before the beginning of the file. If the terminal has a "visual bell", it isused instead. The bell will be rung on certain other errors, such as typing an invalid character. Thedefault is to ring the terminal bell in all such cases.
pager -q ...
-Q
Causes totally "quiet" operation: the terminal bell is never rung.
pager -Q ...
-r
Causes "raw" control characters to be displayed. The default is to display control characters usingthe caret notation; for example, a control-A (octal 001) is displayed as "^A". Warning: when the -roption is used, less cannot keep track of the actual appearance of the screen (since this depends onhow the screen responds to each type of control character). Thus, various display problems may result,such as long lines being split in the wrong place.
pager -r ...
-R
Like -r, but only ANSI "color" escape sequences are output in "raw" form. Unlike -r, the screenappearance is maintained correctly in most cases. ANSI "color" escape sequences are sequences of theform:ESC [ ... mwhere the "..." is zero or more color specification characters For the purpose of keeping track ofscreen appearance, ANSI color escape sequences are assumed to not move the cursor. You can make lessthink that characters other than "m" can end ANSI color escape sequences by setting the environmentvariable LESSANSIENDCHARS to the list of characters which can end a color escape sequence. And you canmake less think that characters other than the standard ones may appear between the ESC and the m bysetting the environment variable LESSANSIMIDCHARS to the list of characters which can appear.
pager -R ...
-s
Causes consecutive blank lines to be squeezed into a single blank line. This is useful when viewingnroff output.
pager -s ...
-S
Causes lines longer than the screen width to be chopped (truncated) rather than wrapped. That is, theportion of a long line that does not fit in the screen width is not shown. The default is to wrap longlines; that is, display the remainder on the next line.
pager -S ...
-ttag
The -t option, followed immediately by a TAG, will edit the file containing that tag. For this towork, tag information must be available; for example, there may be a file in the current directorycalled "tags", which was previously built by ctags (1) or an equivalent command. If the environmentvariable LESSGLOBALTAGS is set, it is taken to be the name of a command compatible with global (1), andthat command is executed to find the tag. (See http://www.gnu.org/software/global/global.html). The
pager -ttag ...
-Ttagsfile
Specifies a tags file to be used instead of "tags".
pager -Ttagsfile ...
-u
Causes backspaces and carriage returns to be treated as printable characters; that is, they are sent tothe terminal when they appear in the input.
pager -u ...
-U
Causes backspaces, tabs and carriage returns to be treated as control characters; that is, they arehandled as specified by the -r option.By default, if neither -u nor -U is given, backspaces which appear adjacent to an underscore characterare treated specially: the underlined text is displayed using the terminal's hardware underlining capa‐bility. Also, backspaces which appear between two identical characters are treated specially: theoverstruck text is printed using the terminal's hardware boldface capability. Other backspaces aredeleted, along with the preceding character. Carriage returns immediately followed by a newline aredeleted. Other carriage returns are handled as specified by the -r option. Text which is overstruckor underlined can be searched for if neither -u nor -U is in effect.
pager -U ...
-V
Displays the version number of less.
pager -V ...
-w
Temporarily highlights the first "new" line after a forward movement of a full page. The first "new"line is the line immediately following the line previously at the bottom of the screen. Also high‐lights the target line after a g or p command. The highlight is removed at the next command whichcauses movement. The entire line is highlighted, unless the -J option is in effect, in which case onlythe status column is highlighted.
pager -w ...
-W
Like -w, but temporarily highlights the first new line after any forward movement command larger thanone line.
pager -W ...
-xn,...
Sets tab stops. If only one n is specified, tab stops are set at multiples of n. If multiple valuesseparated by commas are specified, tab stops are set at those positions, and then continue with thesame spacing as the last two. For example, -x9,17 will set tabs at positions 9, 17, 25, 33, etc. Thedefault for n is 8.
pager -xn,... ...
-X
Disables sending the termcap initialization and deinitialization strings to the terminal. This issometimes desirable if the deinitialization string does something unnecessary, like clearing thescreen.
pager -X ...
-yn
Specifies a maximum number of lines to scroll forward. If it is necessary to scroll forward more thann lines, the screen is repainted instead. The -c or -C option may be used to repaint from the top ofthe screen if desired. By default, any forward movement causes scrolling.
pager -yn ...
-[z]n
Changes the default scrolling window size to n lines. The default is one screenful. The z and w com‐mands can also be used to change the window size. The "z" may be omitted for compatibility with someversions of more. If the number n is negative, it indicates n lines less than the current screen size.For example, if the screen is 24 lines, -z-4 sets the scrolling window to 20 lines. If the screen isresized to 40 lines, the scrolling window automatically changes to 36 lines.
pager -[z]n ...
-"cc
Changes the filename quoting character. This may be necessary if you are trying to name a file whichcontains both spaces and quote characters. Followed by a single character, this changes the quotecharacter to that character. Filenames containing a space should then be surrounded by that characterrather than by double quotes. Followed by two characters, changes the open quote to the first charac‐ter, and the close quote to the second character. Filenames containing a space should then be precededby the open quote character and followed by the close quote character. Note that even after the quotecharacters are changed, this option remains -" (a dash followed by a double quote).
pager -"cc ...
-~
Normally lines after end of file are displayed as a single tilde (~). This option causes lines afterend of file to be displayed as blank lines.
pager -~ ...
-#
Specifies the default number of positions to scroll horizontally in the RIGHTARROW and LEFTARROW com‐mands. If the number specified is zero, it sets the default number of positions to one half of thescreen width. Alternately, the number may be specified as a fraction of the width of the screen,starting with a decimal point: .5 is half of the screen width, .3 is three tenths of the screen width,and so on. If the number is specified as a fraction, the actual number of scroll positions is recalcu‐lated if the terminal window is resized, so that the actual scroll remains at the specified fraction ofthe screen width.
pager -# ...
--follow-name
Normally, if the input file is renamed while an F command is executing, less will continue to displaythe contents of the original file despite its name change. If --follow-name is specified, during an Fcommand less will periodically attempt to reopen the file by name. If the reopen succeeds and the fileis a different file from the original (which means that a new file has been created with the same nameas the original (now renamed) file), less will display the contents of that new file.
pager --follow-name ...
--no-keypad
Disables sending the keypad initialization and deinitialization strings to the terminal. This is some‐times useful if the keypad strings make the numeric keypad behave in an undesirable manner.
pager --no-keypad ...
--use-backslash
This option changes the interpretations of options which follow this one. After the --use-backslashoption, any backslash in an option string is removed and the following character is taken literally.This allows a dollar sign to be included in option strings.
pager --use-backslash ...
-k
use of lesskey files
pager -k ...
-t
metacharacters in filenames, such as *filename completion (TAB, ^L)Less can also be compiled to be permanently in "secure" mode.COMPATIBILITY WITH MOREIf the environment variable LESS_IS_MORE is set to 1, or if the program is invoked via a file link named"more", less behaves (mostly) in conformance with the POSIX "more" command specification. In this mode, lessbehaves differently in these ways:The -e option works differently. If the -e option is not set, less behaves as if the -e option were set. Ifthe -e option is set, less behaves as if the -E option were set.The -m option works differently. If the -m option is not set, the medium prompt is used, and it is prefixedwith the string "--More--". If the -m option is set, the short prompt is used.The -n option acts like the -z option. The normal behavior of the -n option is unavailable in this mode.The parameter to the -p option is taken to be a less command rather than a search pattern.The LESS environment variable is ignored, and the MORE environment variable is used in its place.ENVIRONMENT VARIABLESEnvironment variables may be specified either in the system environment as usual, or in a lesskey (1) file.If environment variables are defined in more than one place, variables defined in a local lesskey file takeprecedence over variables defined in the system environment, which take precedence over variables defined inthe system-wide lesskey file.COLUMNSSets the number of columns on the screen. Takes precedence over the number of columns specified by theTERM variable. (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD, the windowsystem's idea of the screen size takes precedence over the LINES and COLUMNS environment variables.)EDITOR The name of the editor (used for the v command).HOME Name of the user's home directory (used to find a lesskey file on Unix and OS/2 systems).HOMEDRIVE, HOMEPATHConcatenation of the HOMEDRIVE and HOMEPATH environment variables is the name of the user's home direc‐tory if the HOME variable is not set (only in the Windows version).INIT Name of the user's init directory (used to find a lesskey file on OS/2 systems).LANG Language for determining the character set.LC_CTYPELanguage for determining the character set.LESS Options which are passed to less automatically.LESSANSIENDCHARSCharacters which may end an ANSI color escape sequence (default "m").LESSANSIMIDCHARSCharacters which may appear between the ESC character and the end character in an ANSI color escapesequence (default "0123456789:;[?!"'#%()*+ ".LESSBINFMTFormat for displaying non-printable, non-control characters.LESSCHARDEFDefines a character set.LESSCHARSETSelects a predefined character set.LESSCLOSECommand line to invoke the (optional) input-postprocessor.LESSECHOName of the lessecho program (default "lessecho"). The lessecho program is needed to expand metachar‐acters, such as * and ?, in filenames on Unix systems.LESSEDITEditor prototype string (used for the v command). See discussion under PROMPTS.LESSGLOBALTAGSName of the command used by the -t option to find global tags. Normally should be set to "global" ifyour system has the global (1) command. If not set, global tags are not used.LESSHISTFILEName of the history file used to remember search commands and shell commands between invocations ofless. If set to "-" or "/dev/null", a history file is not used. The default is "$HOME/.lesshst" onUnix systems, "$HOME/_lesshst" on DOS and Windows systems, or "$HOME/lesshst.ini" or"$INIT/lesshst.ini" on OS/2 systems.LESSHISTSIZEThe maximum number of commands to save in the history file. The default is 100.LESSKEYName of the default lesskey(1) file.LESSKEY_SYSTEMName of the default system-wide lesskey(1) file.LESSMETACHARSList of characters which are considered "metacharacters" by the shell.LESSMETAESCAPEPrefix which less will add before each metacharacter in a command sent to the shell. If LESSMETAESCAPEis an empty string, commands containing metacharacters will not be passed to the shell.LESSOPENCommand line to invoke the (optional) input-preprocessor.LESSSECURERuns less in "secure" mode. See discussion under SECURITY.LESSSEPARATORString to be appended to a directory name in filename completion.LESSUTFBINFMTFormat for displaying non-printable Unicode code points.LESS_IS_MOREEmulate the more (1) command.LINES Sets the number of lines on the screen. Takes precedence over the number of lines specified by theTERM variable. (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD, the windowsystem's idea of the screen size takes precedence over the LINES and COLUMNS environment variables.)MORE Options which are passed to less automatically when running in more compatible mode.PATH User's search path (used to find a lesskey file on MS-DOS and OS/2 systems).SHELL The shell used to execute the ! command, as well as to expand filenames.TERM The type of terminal on which less is being run.VISUAL The name of the editor (used for the v command).
pager -t ...