]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/less/less.nro
MFC r368207,368607:
[FreeBSD/stable/10.git] / contrib / less / less.nro
1 .TH LESS 1 "Version 530: 05 Dec 2017"
2 .SH NAME
3 less \- opposite of more
4 .SH SYNOPSIS
5 .B "less \-?"
6 .br
7 .B "less \-\-help"
8 .br
9 .B "less \-V"
10 .br
11 .B "less \-\-version"
12 .br
13 .B "less [\-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]"
14 .br
15 .B "     [\-b \fIspace\/\fP] [\-h \fIlines\/\fP] [\-j \fIline\/\fP] [\-k \fIkeyfile\/\fP]"
16 .br
17 .B "     [\-{oO} \fIlogfile\/\fP] [\-p \fIpattern\/\fP] [\-P \fIprompt\/\fP] [\-t \fItag\/\fP]"
18 .br
19 .B "     [\-T \fItagsfile\/\fP] [\-x \fItab\/\fP,...] [\-y \fIlines\/\fP] [\-[z] \fIlines\/\fP]"
20 .br
21 .B "     [\-# \fIshift\/\fP] [+[+]\fIcmd\/\fP] [\-\-] [\fIfilename\/\fP]..."
22 .br
23 (See the OPTIONS section for alternate option syntax with long option names.)
24
25 .SH DESCRIPTION
26 .I Less
27 is a program similar to
28 .I more
29 (1), but which allows backward movement
30 in the file as well as forward movement.
31 Also,
32 .I less
33 does not have to read the entire input file before starting,
34 so with large input files it starts up faster than text editors like
35 .I vi
36 (1).
37 .I Less
38 uses termcap (or terminfo on some systems),
39 so it can run on a variety of terminals.
40 There is even limited support for hardcopy terminals.
41 (On a hardcopy terminal, lines which should be printed at the top
42 of the screen are prefixed with a caret.)
43 .PP
44 Commands are based on both
45 .I more
46 and
47 .IR vi .
48 Commands may be preceded by a decimal number,
49 called N in the descriptions below.
50 The number is used by some commands, as indicated.
51
52 .SH COMMANDS
53 In the following descriptions, ^X means control-X.
54 ESC stands for the ESCAPE key; for example ESC-v means the
55 two character sequence "ESCAPE", then "v".
56 .IP "h or H"
57 Help: display a summary of these commands.
58 If you forget all the other commands, remember this one.
59 .IP "SPACE or ^V or f or ^F"
60 Scroll forward N lines, default one window (see option \-z below).
61 If N is more than the screen size, only the final screenful is displayed.
62 Warning: some systems use ^V as a special literalization character.
63 .IP "z"
64 Like SPACE, but if N is specified, it becomes the new window size.
65 .IP "ESC-SPACE"
66 Like SPACE, but scrolls a full screenful, even if it reaches
67 end-of-file in the process.
68 .IP "ENTER or RETURN or ^N or e or ^E or j or ^J"
69 Scroll forward N lines, default 1.
70 The entire N lines are displayed, even if N is more than the screen size.
71 .IP "d or ^D"
72 Scroll forward N lines, default one half of the screen size.
73 If N is specified, it becomes the new default for
74 subsequent d and u commands.
75 .IP "b or ^B or ESC-v"
76 Scroll backward N lines, default one window (see option \-z below).
77 If N is more than the screen size, only the final screenful is displayed.
78 .IP "w"
79 Like ESC-v, but if N is specified, it becomes the new window size.
80 .IP "y or ^Y or ^P or k or ^K"
81 Scroll backward N lines, default 1.
82 The entire N lines are displayed, even if N is more than the screen size.
83 Warning: some systems use ^Y as a special job control character.
84 .IP "u or ^U"
85 Scroll backward N lines, default one half of the screen size.
86 If N is specified, it becomes the new default for
87 subsequent d and u commands.
88 .IP "J"
89 Like j, but continues to scroll beyond the end of the file.
90 .IP "K or Y"
91 Like k, but continues to scroll beyond the beginning of the file.
92 .IP "ESC-) or RIGHTARROW"
93 Scroll horizontally right N characters, default half the screen width
94 (see the \-# option).
95 If a number N is specified, it becomes the default for future RIGHTARROW
96 and LEFTARROW commands.
97 While the text is scrolled, it acts as though the \-S option
98 (chop lines) were in effect.
99 .IP "ESC-( or LEFTARROW"
100 Scroll horizontally left N characters, default half the screen width
101 (see the \-# option).
102 If a number N is specified, it becomes the default for future RIGHTARROW
103 and LEFTARROW commands.
104 .IP "ESC-} or ^RIGHTARROW"
105 Scroll horizontally right to show the end of the longest displayed line.
106 .IP "ESC-{ or ^LEFTARROW"
107 Scroll horizontally left back to the first column.
108 .IP "r or ^R or ^L"
109 Repaint the screen.
110 .IP R
111 Repaint the screen, discarding any buffered input.
112 Useful if the file is changing while it is being viewed.
113 .IP "F"
114 Scroll forward, and keep trying to read when the
115 end of file is reached.
116 Normally this command would be used when already at the end of the file.
117 It is a way to monitor the tail of a file which is growing
118 while it is being viewed.
119 (The behavior is similar to the "tail \-f" command.)
120 .IP "ESC-F"
121 Like F, but as soon as a line is found which matches
122 the last search pattern, the terminal bell is rung
123 and forward scrolling stops.
124 .IP "g or < or ESC-<"
125 Go to line N in the file, default 1 (beginning of file).
126 (Warning: this may be slow if N is large.)
127 .IP "G or > or ESC->"
128 Go to line N in the file, default the end of the file.
129 (Warning: this may be slow if N is large,
130 or if N is not specified and
131 standard input, rather than a file, is being read.)
132 .IP "ESC-G"
133 Same as G, except if no number N is specified and the input is standard input,
134 goes to the last line which is currently buffered.
135 .IP "p or %"
136 Go to a position N percent into the file.
137 N should be between 0 and 100, and may contain a decimal point.
138 .IP "P"
139 Go to the line containing byte offset N in the file.
140 .IP "{"
141 If a left curly bracket appears in the top line displayed
142 on the screen,
143 the { command will go to the matching right curly bracket.
144 The matching right curly bracket is positioned on the bottom
145 line of the screen.
146 If there is more than one left curly bracket on the top line,
147 a number N may be used to specify the N-th bracket on the line.
148 .IP "}"
149 If a right curly bracket appears in the bottom line displayed
150 on the screen,
151 the } command will go to the matching left curly bracket.
152 The matching left curly bracket is positioned on the top
153 line of the screen.
154 If there is more than one right curly bracket on the top line,
155 a number N may be used to specify the N-th bracket on the line.
156 .IP "("
157 Like {, but applies to parentheses rather than curly brackets.
158 .IP ")"
159 Like }, but applies to parentheses rather than curly brackets.
160 .IP "["
161 Like {, but applies to square brackets rather than curly brackets.
162 .IP "]"
163 Like }, but applies to square brackets rather than curly brackets.
164 .IP "ESC-^F"
165 Followed by two characters,
166 acts like {, but uses the two characters as open and close brackets,
167 respectively.
168 For example, "ESC ^F < >" could be used to
169 go forward to the > which matches the < in the top displayed line.
170 .IP "ESC-^B"
171 Followed by two characters,
172 acts like }, but uses the two characters as open and close brackets,
173 respectively.
174 For example, "ESC ^B < >" could be used to
175 go backward to the < which matches the > in the bottom displayed line.
176 .IP m
177 Followed by any lowercase or uppercase letter,
178 marks the first displayed line with that letter.
179 If the status column is enabled via the \-J option,
180 the status column shows the marked line.
181 .IP M
182 Acts like m, except the last displayed line is marked
183 rather than the first displayed line.
184 .IP "'"
185 (Single quote.)
186 Followed by any lowercase or uppercase letter, returns to the position which
187 was previously marked with that letter.
188 Followed by another single quote, returns to the position at
189 which the last "large" movement command was executed.
190 Followed by a ^ or $, jumps to the beginning or end of the
191 file respectively.
192 Marks are preserved when a new file is examined,
193 so the ' command can be used to switch between input files.
194 .IP "^X^X"
195 Same as single quote.
196 .IP "ESC-m"
197 Followed by any lowercase or uppercase letter,
198 clears the mark identified by that letter.
199 .IP /pattern
200 Search forward in the file for the N-th line containing the pattern.
201 N defaults to 1.
202 The pattern is a regular expression, as recognized by
203 the regular expression library supplied by your system.
204 The search starts at the first line displayed
205 (but see the \-a and \-j options, which change this).
206 .sp
207 Certain characters are special
208 if entered at the beginning of the pattern;
209 they modify the type of search rather than become part of the pattern:
210 .RS
211 .IP "^N or !"
212 Search for lines which do NOT match the pattern.
213 .IP "^E or *"
214 Search multiple files.
215 That is, if the search reaches the END of the current file
216 without finding a match,
217 the search continues in the next file in the command line list.
218 .IP "^F or @"
219 Begin the search at the first line of the FIRST file
220 in the command line list,
221 regardless of what is currently displayed on the screen
222 or the settings of the \-a or \-j options.
223 .IP "^K"
224 Highlight any text which matches the pattern on the current screen,
225 but don't move to the first match (KEEP current position).
226 .IP "^R"
227 Don't interpret regular expression metacharacters;
228 that is, do a simple textual comparison.
229 .RE
230 .IP ?pattern
231 Search backward in the file for the N-th line containing the pattern.
232 The search starts at the last line displayed 
233 (but see the \-a and \-j options, which change this).
234 .sp
235 Certain characters are special as in the / command:
236 .RS
237 .IP "^N or !"
238 Search for lines which do NOT match the pattern.
239 .IP "^E or *"
240 Search multiple files.
241 That is, if the search reaches the beginning of the current file
242 without finding a match,
243 the search continues in the previous file in the command line list.
244 .IP "^F or @"
245 Begin the search at the last line of the last file
246 in the command line list,
247 regardless of what is currently displayed on the screen
248 or the settings of the \-a or \-j options.
249 .IP "^K"
250 As in forward searches.
251 .IP "^R"
252 As in forward searches.
253 .RE
254 .IP "ESC-/pattern"
255 Same as "/*".
256 .IP "ESC-?pattern"
257 Same as "?*".
258 .IP n
259 Repeat previous search, for N-th line containing the last pattern.
260 If the previous search was modified by ^N, the search is made for the
261 N-th line NOT containing the pattern.
262 If the previous search was modified by ^E, the search continues
263 in the next (or previous) file if not satisfied in the current file.
264 If the previous search was modified by ^R, the search is done
265 without using regular expressions.
266 There is no effect if the previous search was modified by ^F or ^K.
267 .IP N
268 Repeat previous search, but in the reverse direction.
269 .IP "ESC-n"
270 Repeat previous search, but crossing file boundaries.
271 The effect is as if the previous search were modified by *.
272 .IP "ESC-N"
273 Repeat previous search, but in the reverse direction
274 and crossing file boundaries.
275 .IP "ESC-u"
276 Undo search highlighting.
277 Turn off highlighting of strings matching the current search pattern.
278 If highlighting is already off because of a previous ESC-u command,
279 turn highlighting back on.
280 Any search command will also turn highlighting back on.
281 (Highlighting can also be disabled by toggling the \-G option;
282 in that case search commands do not turn highlighting back on.)
283 .IP "&pattern"
284 Display only lines which match the pattern;
285 lines which do not match the pattern are not displayed.
286 If pattern is empty (if you type & immediately followed by ENTER),
287 any filtering is turned off, and all lines are displayed.
288 While filtering is in effect, an ampersand is displayed at the
289 beginning of the prompt,
290 as a reminder that some lines in the file may be hidden.
291 .sp
292 Certain characters are special as in the / command:
293 .RS
294 .IP "^N or !"
295 Display only lines which do NOT match the pattern.
296 .IP "^R"
297 Don't interpret regular expression metacharacters;
298 that is, do a simple textual comparison.
299 .RE
300 .IP ":e [filename]"
301 Examine a new file.
302 If the filename is missing, the "current" file (see the :n and :p commands
303 below) from the list of files in the command line is re-examined.
304 A percent sign (%) in the filename is replaced by the name of the
305 current file.
306 A pound sign (#) is replaced by the name of the previously examined file.
307 However, two consecutive percent signs are simply
308 replaced with a single percent sign.
309 This allows you to enter a filename that contains a percent sign
310 in the name.
311 Similarly, two consecutive pound signs are replaced with a single pound sign.
312 The filename is inserted into the command line list of files
313 so that it can be seen by subsequent :n and :p commands.
314 If the filename consists of several files, they are all inserted into
315 the list of files and the first one is examined.
316 If the filename contains one or more spaces,
317 the entire filename should be enclosed in double quotes
318 (also see the \-" option).
319 .IP "^X^V or E"
320 Same as :e.
321 Warning: some systems use ^V as a special literalization character.
322 On such systems, you may not be able to use ^V.
323 .IP ":n"
324 Examine the next file (from the list of files given in the command line).
325 If a number N is specified, the N-th next file is examined.
326 .IP ":p"
327 Examine the previous file in the command line list.
328 If a number N is specified, the N-th previous file is examined.
329 .IP ":x"
330 Examine the first file in the command line list.
331 If a number N is specified, the N-th file in the list is examined.
332 .IP ":d"
333 Remove the current file from the list of files.
334 .IP "t"
335 Go to the next tag, if there were more than one matches for the current tag.
336 See the \-t option for more details about tags.
337 .IP "T"
338 Go to the previous tag, if there were more than one matches for the current tag.
339 .IP "= or ^G or :f"
340 Prints some information about the file being viewed,
341 including its name
342 and the line number and byte offset of the bottom line being displayed.
343 If possible, it also prints the length of the file,
344 the number of lines in the file
345 and the percent of the file above the last displayed line.
346 .IP \-
347 Followed by one of the command line option letters (see OPTIONS below),
348 this will change the setting of that option
349 and print a message describing the new setting.
350 If a ^P (CONTROL-P) is entered immediately after the dash,
351 the setting of the option is changed but no message is printed.
352 If the option letter has a numeric value (such as \-b or \-h),
353 or a string value (such as \-P or \-t),
354 a new value may be entered after the option letter.
355 If no new value is entered, a message describing
356 the current setting is printed and nothing is changed.
357 .IP \-\-
358 Like the \- command, but takes a long option name (see OPTIONS below)
359 rather than a single option letter.
360 You must press ENTER or RETURN after typing the option name.
361 A ^P immediately after the second dash suppresses printing of a
362 message describing the new setting, as in the \- command.
363 .IP \-+
364 Followed by one of the command line option letters
365 this will reset the option to its default setting
366 and print a message describing the new setting.
367 (The "\-+\fIX\fP" command does the same thing
368 as "\-+\fIX\fP" on the command line.)
369 This does not work for string-valued options.
370 .IP \-\-+
371 Like the \-+ command, but takes a long option name
372 rather than a single option letter.
373 .IP \-!
374 Followed by one of the command line option letters,
375 this will reset the option to the "opposite" of its default setting
376 and print a message describing the new setting.
377 This does not work for numeric or string-valued options.
378 .IP \-\-!
379 Like the \-! command, but takes a long option name
380 rather than a single option letter.
381 .IP _
382 (Underscore.)
383 Followed by one of the command line option letters,
384 this will print a message describing the current setting of that option.
385 The setting of the option is not changed.
386 .IP __
387 (Double underscore.)
388 Like the _ (underscore) command, but takes a long option name
389 rather than a single option letter.
390 You must press ENTER or RETURN after typing the option name.
391 .IP +cmd
392 Causes the specified cmd to be executed each time a new file is examined.
393 For example, +G causes
394 .I less
395 to initially display each file starting at the end
396 rather than the beginning.
397 .IP V
398 Prints the version number of
399 .I less
400 being run.
401 .IP "q or Q or :q or :Q or ZZ"
402 Exits
403 .IR less .
404 .PP
405 The following
406 four
407 commands may or may not be valid, depending on your particular installation.
408 .PP
409 .IP v
410 Invokes an editor to edit the current file being viewed.
411 The editor is taken from the environment variable VISUAL if defined,
412 or EDITOR if VISUAL is not defined,
413 or defaults to "vi" if neither VISUAL nor EDITOR is defined.
414 See also the discussion of LESSEDIT under the section on PROMPTS below.
415 .IP "! shell-command"
416 Invokes a shell to run the shell-command given.
417 A percent sign (%) in the command is replaced by the name of the
418 current file.
419 A pound sign (#) is replaced by the name of the previously examined file.
420 "!!" repeats the last shell command.
421 "!" with no shell command simply invokes a shell.
422 On Unix systems, the shell is taken from the environment variable SHELL,
423 or defaults to "sh".
424 On MS-DOS and OS/2 systems, the shell is the normal command processor.
425 .IP "| <m> shell-command"
426 <m> represents any mark letter.
427 Pipes a section of the input file to the given shell command.
428 The section of the file to be piped is between the position marked by 
429 the letter and the current screen.
430 The entire current screen is included, regardless of whether the
431 marked position is before or after the current screen.
432 <m> may also be ^ or $ to indicate beginning or end of file respectively.
433 If <m> is \&.\& or newline, the current screen is piped.
434 .IP "s filename"
435 Save the input to a file.
436 This only works if the input is a pipe, not an ordinary file.
437 .PP
438 .SH OPTIONS
439 Command line options are described below.
440 Most options may be changed while
441 .I less
442 is running, via the "\-" command.
443 .PP
444 Most options may be given in one of two forms:
445 either a dash followed by a single letter,
446 or two dashes followed by a long option name.
447 A long option name may be abbreviated as long as
448 the abbreviation is unambiguous.
449 For example, \-\-quit-at-eof may be abbreviated \-\-quit, but not
450 \-\-qui, since both \-\-quit-at-eof and \-\-quiet begin with \-\-qui.
451 Some long option names are in uppercase, such as \-\-QUIT-AT-EOF, as
452 distinct from \-\-quit-at-eof.
453 Such option names need only have their first letter capitalized;
454 the remainder of the name may be in either case.
455 For example, \-\-Quit-at-eof is equivalent to \-\-QUIT-AT-EOF.
456 .PP
457 Options are also taken from the environment variable "LESS".
458 For example,
459 to avoid typing "less \-options \&...\&" each time
460 .I less
461 is invoked, you might tell
462 .IR csh :
463 .sp
464 setenv LESS "\-options"
465 .sp
466 or if you use
467 .IR sh :
468 .sp
469 LESS="\-options"; export LESS
470 .sp
471 On MS-DOS, you don't need the quotes, but you should replace any
472 percent signs in the options string by double percent signs.
473 .sp
474 The environment variable is parsed before the command line,
475 so command line options override the LESS environment variable.
476 If an option appears in the LESS variable, it can be reset
477 to its default value on the command line by beginning the command
478 line option with "\-+".
479 .sp
480 Some options like \-k or \-D require a string to follow the option letter.
481 The string for that option is considered to end when a dollar sign ($) is found.
482 For example, you can set two \-D options on MS-DOS like this:
483 .sp
484 LESS="Dn9.1$Ds4.1"
485 .sp
486 If the \-\-use-backslash option appears earlier in the options, then
487 a dollar sign or backslash may be included literally in an option string
488 by preceding it with a backslash.
489 If the \-\-use-backslash option is not in effect, then backslashes are
490 not treated specially, and there is no way to include a dollar sign
491 in the option string.
492 .IP "\-? or \-\-help"
493 This option displays a summary of the commands accepted by
494 .I less
495 (the same as the h command).
496 (Depending on how your shell interprets the question mark,
497 it may be necessary to quote the question mark, thus: "\-\e?".)
498 .IP "\-a or \-\-search-skip-screen"
499 By default, forward searches start at the top of the displayed screen
500 and backwards searches start at the bottom of the displayed screen
501 (except for repeated searches invoked by the n or N commands,
502 which start after or before the "target" line respectively;
503 see the \-j option for more about the target line).
504 The \-a option causes forward searches to instead start at
505 the bottom of the screen
506 and backward searches to start at the top of the screen,
507 thus skipping all lines displayed on the screen.
508 .IP "\-A or \-\-SEARCH-SKIP-SCREEN"
509 Causes all forward searches (not just non-repeated searches)
510 to start just after the target line, and all backward searches
511 to start just before the target line.
512 Thus, forward searches will skip part of the displayed screen
513 (from the first line up to and including the target line).
514 Similarly backwards searches will skip the displayed screen
515 from the last line up to and including the target line.
516 This was the default behavior in less versions prior to 441.
517 .IP "\-b\fIn\fP or \-\-buffers=\fIn\fP"
518 Specifies the amount of buffer space
519 .I less
520 will use for each file, in units of kilobytes (1024 bytes).
521 By default 64\ K of buffer space is used for each file
522 (unless the file is a pipe; see the \-B option).
523 The \-b option specifies instead that \fIn\fP kilobytes of
524 buffer space should be used for each file.
525 If \fIn\fP is \-1, buffer space is unlimited; that is,
526 the entire file can be read into memory.
527 .IP "\-B or \-\-auto-buffers"
528 By default, when data is read from a pipe,
529 buffers are allocated automatically as needed.
530 If a large amount of data is read from the pipe, this can cause
531 a large amount of memory to be allocated.
532 The \-B option disables this automatic allocation of buffers for pipes,
533 so that only 64\ K
534 (or the amount of space specified by the \-b option)
535 is used for the pipe.
536 Warning: use of \-B can result in erroneous display, since only the
537 most recently viewed part of the piped data is kept in memory;
538 any earlier data is lost.
539 .IP "\-c or \-\-clear-screen"
540 Causes full screen repaints to be painted from the top line down.
541 By default,
542 full screen repaints are done by scrolling from the bottom of the screen.
543 .IP "\-C or \-\-CLEAR-SCREEN"
544 Same as \-c, for compatibility with older versions of
545 .IR less .
546 .IP "\-d or \-\-dumb"
547 The \-d option suppresses the error message
548 normally displayed if the terminal is dumb;
549 that is, lacks some important capability,
550 such as the ability to clear the screen or scroll backward.
551 The \-d option does not otherwise change the behavior of
552 .I less
553 on a dumb terminal.
554 .IP "\-D\fBx\fP\fIcolor\fP or \-\-color=\fBx\fP\fIcolor\fP"
555 [MS-DOS only]
556 Sets the color of the text displayed.
557 \fBx\fP is a single character which selects the type of text whose color is
558 being set: n=normal, s=standout, d=bold, u=underlined, k=blink.
559 \fIcolor\fP is a pair of numbers separated by a period.
560 The first number selects the foreground color and the second selects
561 the background color of the text.
562 A single number \fIN\fP is the same as \fIN.M\fP,
563 where \fIM\fP is the normal background color.
564 The color may start or end with \fBu\fP to use underline (with the normal
565 color, if by itself), if the system supports it (Windows only).
566 \fBx\fP may also be \fBa\fP to toggle strict ANSI sequence rendering (SGR mode).
567
568 .IP "\-e or \-\-quit-at-eof"
569 Causes
570 .I less
571 to automatically exit
572 the second time it reaches end-of-file.
573 By default, the only way to exit
574 .I less
575 is via the "q" command.
576 .IP "\-E or \-\-QUIT-AT-EOF"
577 Causes
578 .I less
579 to automatically exit the first time it reaches end-of-file.
580 .IP "\-f or \-\-force"
581 Forces non-regular files to be opened.
582 (A non-regular file is a directory or a device special file.)
583 Also suppresses the warning message when a binary file is opened.
584 By default,
585 .I less
586 will refuse to open non-regular files.
587 Note that some operating systems will not allow directories
588 to be read, even if \-f is set.
589 .IP "\-F or \-\-quit-if-one-screen"
590 Causes
591 .I less
592 to automatically exit
593 if the entire file can be displayed on the first screen.
594 .IP "\-g or \-\-hilite-search"
595 Normally,
596 .I less
597 will highlight ALL strings which match the last search command.
598 The \-g option changes this behavior to highlight only the particular string
599 which was found by the last search command.
600 This can cause
601 .I less
602 to run somewhat faster than the default.
603 .IP "\-G or \-\-HILITE-SEARCH"
604 The \-G option suppresses all highlighting of strings found by search commands.
605 .IP "\-h\fIn\fP or \-\-max-back-scroll=\fIn\fP"
606 Specifies a maximum number of lines to scroll backward.
607 If it is necessary to scroll backward more than \fIn\fP lines,
608 the screen is repainted in a forward direction instead.
609 (If the terminal does not have the ability to scroll
610 backward, \-h0 is implied.)
611 .IP "\-i or \-\-ignore-case"
612 Causes searches to ignore case; that is,
613 uppercase and lowercase are considered identical.
614 This option is ignored if any uppercase letters
615 appear in the search pattern;
616 in other words,
617 if a pattern contains uppercase letters, then that search does not ignore case.
618 .IP "\-I or \-\-IGNORE-CASE"
619 Like \-i, but searches ignore case even if
620 the pattern contains uppercase letters.
621 .IP "\-j\fIn\fP or \-\-jump-target=\fIn\fP"
622 Specifies a line on the screen where the "target" line
623 is to be positioned.
624 The target line is the line specified by any command to
625 search for a pattern, jump to a line number,
626 jump to a file percentage or jump to a tag.
627 The screen line may be specified by a number: the top line on the screen
628 is 1, the next is 2, and so on.
629 The number may be negative to specify a line relative to the bottom
630 of the screen: the bottom line on the screen is \-1, the second
631 to the bottom is \-2, and so on.
632 Alternately, the screen line may be specified as a fraction of the height
633 of the screen, starting with a decimal point: \&.5 is in the middle of the
634 screen, \&.3 is three tenths down from the first line, and so on.
635 If the line is specified as a fraction, the actual line number
636 is recalculated if the terminal window is resized, so that the
637 target line remains at the specified fraction of the screen height.
638 If any form of the \-j option is used,
639 repeated forward searches (invoked with "n" or "N")
640 begin at the line immediately after the target line,
641 and repeated backward searches begin at the target line,
642 unless changed by \-a or \-A.
643 For example, if "\-j4" is used, the target line is the
644 fourth line on the screen, so forward searches begin at the fifth line
645 on the screen.
646 However nonrepeated searches (invoked with "/" or "?")
647 always begin at the start or end of the current screen respectively.
648 .IP "\-J or \-\-status-column"
649 Displays a status column at the left edge of the screen.
650 The status column shows the lines that matched the current search,
651 and any lines that are marked (via the m or M command).
652 The status column is also used if the \-w or \-W option is in effect.
653 .IP "\-k\fIfilename\fP or \-\-lesskey-file=\fIfilename\fP"
654 Causes
655 .I less
656 to open and interpret the named file as a
657 .I lesskey
658 (1) file.
659 Multiple \-k options may be specified.
660 If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or
661 if a lesskey file is found in a standard place (see KEY BINDINGS),
662 it is also used as a
663 .I lesskey
664 file.
665 .IP "\-K or \-\-quit-on-intr"
666 Causes
667 .I less
668 to exit immediately (with status 2)
669 when an interrupt character (usually ^C) is typed.
670 Normally, an interrupt character causes
671 .I less
672 to stop whatever it is doing and return to its command prompt.
673 Note that use of this option makes it impossible to return to the
674 command prompt from the "F" command.
675 .IP "\-L or \-\-no-lessopen"
676 Ignore the LESSOPEN environment variable
677 (see the INPUT PREPROCESSOR section below).
678 This option can be set from within \fIless\fP,
679 but it will apply only to files opened subsequently, not to the
680 file which is currently open.
681 .IP "\-m or \-\-long-prompt"
682 Causes
683 .I less
684 to prompt verbosely (like \fImore\fP),
685 with the percent into the file.
686 By default,
687 .I less
688 prompts with a colon.
689 .IP "\-M or \-\-LONG-PROMPT"
690 Causes
691 .I less
692 to prompt even more verbosely than
693 .IR more .
694 .IP "\-n or \-\-line-numbers"
695 Suppresses line numbers.
696 The default (to use line numbers) may cause
697 .I less
698 to run more slowly in some cases, especially with a very large input file.
699 Suppressing line numbers with the \-n option will avoid this problem.
700 Using line numbers means: the line number will be displayed in the verbose
701 prompt and in the = command,
702 and the v command will pass the current line number to the editor
703 (see also the discussion of LESSEDIT in PROMPTS below).
704 .IP "\-N or \-\-LINE-NUMBERS"
705 Causes a line number to be displayed at the beginning of
706 each line in the display.
707 .IP "\-o\fIfilename\fP or \-\-log-file=\fIfilename\fP"
708 Causes
709 .I less
710 to copy its input to the named file as it is being viewed.
711 This applies only when the input file is a pipe,
712 not an ordinary file.
713 If the file already exists,
714 .I less
715 will ask for confirmation before overwriting it.
716 .IP "\-O\fIfilename\fP or \-\-LOG-FILE=\fIfilename\fP"
717 The \-O option is like \-o, but it will overwrite an existing
718 file without asking for confirmation.
719 .sp
720 If no log file has been specified,
721 the \-o and \-O options can be used from within
722 .I less
723 to specify a log file.
724 Without a file name, they will simply report the name of the log file.
725 The "s" command is equivalent to specifying \-o from within
726 .IR less .
727 .IP "\-p\fIpattern\fP or \-\-pattern=\fIpattern\fP"
728 The \-p option on the command line is equivalent to
729 specifying +/\fIpattern\fP;
730 that is, it tells
731 .I less
732 to start at the first occurrence of \fIpattern\fP in the file.
733 .IP "\-P\fIprompt\fP or \-\-prompt=\fIprompt\fP"
734 Provides a way to tailor the three prompt
735 styles to your own preference.
736 This option would normally be put in the LESS environment
737 variable, rather than being typed in with each
738 .I less
739 command.
740 Such an option must either be the last option in the LESS variable,
741 or be terminated by a dollar sign.
742  \-Ps followed by a string changes the default (short) prompt
743 to that string.
744  \-Pm changes the medium (\-m) prompt.
745  \-PM changes the long (\-M) prompt.
746  \-Ph changes the prompt for the help screen.
747  \-P= changes the message printed by the = command.
748  \-Pw changes the message printed while waiting for data (in the F command).
749
750 All prompt strings consist of a sequence of
751 letters and special escape sequences.
752 See the section on PROMPTS for more details.
753 .IP "\-q or \-\-quiet or \-\-silent"
754 Causes moderately "quiet" operation:
755 the terminal bell is not rung
756 if an attempt is made to scroll past the end of the file
757 or before the beginning of the file.
758 If the terminal has a "visual bell", it is used instead.
759 The bell will be rung on certain other errors,
760 such as typing an invalid character.
761 The default is to ring the terminal bell in all such cases.
762 .IP "\-Q or \-\-QUIET or \-\-SILENT"
763 Causes totally "quiet" operation:
764 the terminal bell is never rung.
765 .IP "\-r or \-\-raw-control-chars"
766 Causes "raw" control characters to be displayed.
767 The default is to display control characters using the caret notation;
768 for example, a control-A (octal 001) is displayed as "^A".
769 Warning: when the \-r option is used,
770 .I less
771 cannot keep track of the actual appearance of the screen
772 (since this depends on how the screen responds to
773 each type of control character).
774 Thus, various display problems may result,
775 such as long lines being split in the wrong place.
776 .IP "\-R or \-\-RAW-CONTROL-CHARS"
777 Like \-r, but only ANSI "color" escape sequences are output in "raw" form.
778 Unlike \-r, the screen appearance is maintained correctly in most cases.
779 ANSI "color" escape sequences are sequences of the form:
780 .sp
781         ESC [ \&...\& m
782 .sp
783 where the "...\&" is zero or more color specification characters
784 For the purpose of keeping track of screen appearance,
785 ANSI color escape sequences are assumed to not move the cursor.
786 You can make
787 .I less
788 think that characters other than "m" can end ANSI color escape sequences
789 by setting the environment variable LESSANSIENDCHARS to the list of
790 characters which can end a color escape sequence.
791 And you can make
792 .I less
793 think that characters other than the standard ones may appear between
794 the ESC and the m by setting the environment variable LESSANSIMIDCHARS
795 to the list of characters which can appear.
796 .IP "\-s or \-\-squeeze-blank-lines"
797 Causes consecutive blank lines to be squeezed into a single blank line.
798 This is useful when viewing
799 .I nroff
800 output.
801 .IP "\-S or \-\-chop-long-lines"
802 Causes lines longer than the screen width to be
803 chopped (truncated) rather than wrapped.
804 That is, the portion of a long line that does not fit in
805 the screen width is not shown.
806 The default is to wrap long lines; that is, display the remainder
807 on the next line.
808 .IP "\-t\fItag\fP or \-\-tag=\fItag\fP"
809 The \-t option, followed immediately by a TAG,
810 will edit the file containing that tag.
811 For this to work, tag information must be available;
812 for example, there may be a file in the current directory called "tags",
813 which was previously built by
814 .I ctags
815 (1) or an equivalent command.
816 If the environment variable LESSGLOBALTAGS is set, it is taken to be
817 the name of a command compatible with
818 .I global
819 (1), and that command is executed to find the tag.
820 (See http://www.gnu.org/software/global/global.html).
821 The \-t option may also be specified from within
822 .I less
823 (using the \- command) as a way of examining a new file.
824 The command ":t" is equivalent to specifying \-t from within
825 .IR less .
826 .IP "\-T\fItagsfile\fP or \-\-tag-file=\fItagsfile\fP"
827 Specifies a tags file to be used instead of "tags".
828 .IP "\-u or \-\-underline-special"
829 Causes backspaces and carriage returns to be treated as printable characters;
830 that is, they are sent to the terminal when they appear in the input.
831 .IP "\-U or \-\-UNDERLINE-SPECIAL"
832 Causes backspaces, tabs, carriage returns and "formatting characters"
833 (as defined by Unicode) to be treated as control characters;
834 that is, they are handled as specified by the \-r option.
835 .sp
836 By default, if neither \-u nor \-U is given,
837 backspaces which appear adjacent to an underscore character
838 are treated specially:
839 the underlined text is displayed
840 using the terminal's hardware underlining capability.
841 Also, backspaces which appear between two identical characters
842 are treated specially:
843 the overstruck text is printed
844 using the terminal's hardware boldface capability.
845 Other backspaces are deleted, along with the preceding character.
846 Carriage returns immediately followed by a newline are deleted.
847 Other carriage returns are handled as specified by the \-r option.
848 Text which is overstruck or underlined can be searched for
849 if neither \-u nor \-U is in effect.
850 .IP "\-V or \-\-version"
851 Displays the version number of
852 .IR less .
853 .IP "\-w or \-\-hilite-unread"
854 Temporarily highlights the first "new" line after a forward movement
855 of a full page.
856 The first "new" line is the line immediately following the line previously
857 at the bottom of the screen.
858 Also highlights the target line after a g or p command.
859 The highlight is removed at the next command which causes movement.
860 The entire line is highlighted, unless the \-J option is in effect,
861 in which case only the status column is highlighted.
862 .IP "\-W or \-\-HILITE-UNREAD"
863 Like \-w, but temporarily highlights the first new line after any
864 forward movement command larger than one line.
865 .IP "\-x\fIn\fP,...\& or \-\-tabs=\fIn\fP,..."
866 Sets tab stops.
867 If only one \fIn\fP is specified, tab stops are set at multiples of \fIn\fP.
868 If multiple values separated by commas are specified, tab stops
869 are set at those positions, and then continue with the same spacing as the
870 last two.
871 For example, \fI-x9,17\fP will set tabs at positions 9, 17, 25, 33, etc.
872 The default for \fIn\fP is 8.
873 .IP "\-X or \-\-no-init"
874 Disables sending the termcap initialization and deinitialization strings
875 to the terminal.
876 This is sometimes desirable if the deinitialization string does
877 something unnecessary, like clearing the screen.
878 .IP "\-y\fIn\fP or \-\-max-forw-scroll=\fIn\fP"
879 Specifies a maximum number of lines to scroll forward.
880 If it is necessary to scroll forward more than \fIn\fP lines,
881 the screen is repainted instead.
882 The \-c or \-C option may be used to repaint from the top of
883 the screen if desired.
884 By default, any forward movement causes scrolling.
885 .IP "\-z\fIn\fP or \-\-window=\fIn\fP or \-\fIn\fP"
886 Changes the default scrolling window size to \fIn\fP lines.
887 The default is one screenful.
888 The z and w commands can also be used to change the window size.
889 The "z" may be omitted for compatibility with some versions of
890 .IR more .
891 If the number
892 .I n
893 is negative, it indicates
894 .I n
895 lines less than the current screen size.
896 For example, if the screen is 24 lines, \fI\-z\-4\fP sets the
897 scrolling window to 20 lines.  If the screen is resized to 40 lines,
898 the scrolling window automatically changes to 36 lines.
899 .IP "\-\(dq\fIcc\fP\ or\ \-\-quotes=\fIcc\fP"
900 Changes the filename quoting character.
901 This may be necessary if you are trying to name a file
902 which contains both spaces and quote characters.
903 Followed by a single character, this changes the quote character to that
904 character.
905 Filenames containing a space should then be surrounded by that character
906 rather than by double quotes.
907 Followed by two characters, changes the open quote to the first character,
908 and the close quote to the second character.
909 Filenames containing a space should then be preceded by the open quote
910 character and followed by the close quote character.
911 Note that even after the quote characters are changed, this option
912 remains \-" (a dash followed by a double quote).
913 .IP "\-~ or \-\-tilde"
914 Normally lines after end of file are displayed as a single tilde (~).
915 This option causes lines after end of file to be displayed as blank lines.
916 .IP "\-# or \-\-shift"
917 Specifies the default number of positions to scroll horizontally
918 in the RIGHTARROW and LEFTARROW commands.
919 If the number specified is zero, it sets the default number of
920 positions to one half of the screen width.
921 Alternately, the number may be specified as a fraction of the width
922 of the screen, starting with a decimal point: \&.5 is half of the
923 screen width, \&.3 is three tenths of the screen width, and so on.
924 If the number is specified as a fraction, the actual number of
925 scroll positions is recalculated if the terminal window is resized,
926 so that the actual scroll remains at the specified fraction
927 of the screen width.
928 .IP "\-\-follow-name"
929 Normally, if the input file is renamed while an F command is executing,
930 .I less
931 will continue to display the contents of the original file despite
932 its name change.
933 If \-\-follow-name is specified, during an F command
934 .I less
935 will periodically attempt to reopen the file by name.
936 If the reopen succeeds and the file is a different file from the original
937 (which means that a new file has been created
938 with the same name as the original (now renamed) file),
939 .I less
940 will display the contents of that new file.
941 .IP "\-\-no-keypad"
942 Disables sending the keypad initialization and deinitialization strings
943 to the terminal.
944 This is sometimes useful if the keypad strings make the numeric
945 keypad behave in an undesirable manner.
946 .IP "\-\-use-backslash"
947 This option changes the interpretations of options which follow this one.
948 After the \-\-use-backslash option, any backslash in an option string is
949 removed and the following character is taken literally.
950 This allows a dollar sign to be included in option strings.
951 .IP "\-\-rscroll"
952 This option changes the character used to mark truncated lines.
953 It may begin with a two-character attribute indicator like LESSBINFMT does.
954 If there is no attribute indicator, standout is used.
955 If set to "-", truncated lines are not marked.
956 .IP \-\-
957 A command line argument of "\-\-" marks the end of option arguments.
958 Any arguments following this are interpreted as filenames.
959 This can be useful when viewing a file whose name begins with a "\-" or "+".
960 .IP +
961 If a command line option begins with \fB+\fP,
962 the remainder of that option is taken to be an initial command to
963 .IR less .
964 For example, +G tells
965 .I less
966 to start at the end of the file rather than the beginning,
967 and +/xyz tells it to start at the first occurrence of "xyz" in the file.
968 As a special case, +<number> acts like +<number>g;
969 that is, it starts the display at the specified line number
970 (however, see the caveat under the "g" command above).
971 If the option starts with ++, the initial command applies to
972 every file being viewed, not just the first one.
973 The + command described previously
974 may also be used to set (or change) an initial command for every file.
975
976 .SH "LINE EDITING"
977 When entering command line at the bottom of the screen
978 (for example, a filename for the :e command,
979 or the pattern for a search command),
980 certain keys can be used to manipulate the command line.
981 Most commands have an alternate form in [ brackets ] which can be used if
982 a key does not exist on a particular keyboard.
983 (Note that the forms beginning with ESC do not work
984 in some MS-DOS and Windows systems because ESC is the line erase character.)
985 Any of these special keys may be entered literally by preceding
986 it with the "literal" character, either ^V or ^A.
987 A backslash itself may also be entered literally by entering two backslashes.
988 .IP "LEFTARROW [ ESC-h ]"
989 Move the cursor one space to the left.
990 .IP "RIGHTARROW [ ESC-l ]"
991 Move the cursor one space to the right.
992 .IP "^LEFTARROW [ ESC-b or ESC-LEFTARROW ]"
993 (That is, CONTROL and LEFTARROW simultaneously.)
994 Move the cursor one word to the left.
995 .IP "^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]"
996 (That is, CONTROL and RIGHTARROW simultaneously.)
997 Move the cursor one word to the right.
998 .IP "HOME [ ESC-0 ]"
999 Move the cursor to the beginning of the line.
1000 .IP "END [ ESC-$ ]"
1001 Move the cursor to the end of the line.
1002 .IP "BACKSPACE"
1003 Delete the character to the left of the cursor,
1004 or cancel the command if the command line is empty.
1005 .IP "DELETE or [ ESC-x ]"
1006 Delete the character under the cursor.
1007 .IP "^BACKSPACE [ ESC-BACKSPACE ]"
1008 (That is, CONTROL and BACKSPACE simultaneously.)
1009 Delete the word to the left of the cursor.
1010 .IP "^DELETE [ ESC-X or ESC-DELETE ]"
1011 (That is, CONTROL and DELETE simultaneously.)
1012 Delete the word under the cursor.
1013 .IP "UPARROW [ ESC-k ]"
1014 Retrieve the previous command line.
1015 If you first enter some text and then press UPARROW,
1016 it will retrieve the previous command which begins with that text.
1017 .IP "DOWNARROW [ ESC-j ]"
1018 Retrieve the next command line.
1019 If you first enter some text and then press DOWNARROW,
1020 it will retrieve the next command which begins with that text.
1021 .IP "TAB"
1022 Complete the partial filename to the left of the cursor.
1023 If it matches more than one filename, the first match
1024 is entered into the command line.
1025 Repeated TABs will cycle thru the other matching filenames.
1026 If the completed filename is a directory, a "/" is appended to the filename.
1027 (On MS-DOS systems, a "\e" is appended.)
1028 The environment variable LESSSEPARATOR can be used to specify a
1029 different character to append to a directory name.
1030 .IP "BACKTAB [ ESC-TAB ]"
1031 Like, TAB, but cycles in the reverse direction thru the matching filenames.
1032 .IP "^L"
1033 Complete the partial filename to the left of the cursor.
1034 If it matches more than one filename, all matches are entered into
1035 the command line (if they fit).
1036 .IP "^U (Unix and OS/2) or ESC (MS-DOS)"
1037 Delete the entire command line,
1038 or cancel the command if the command line is empty.
1039 If you have changed your line-kill character in Unix to something
1040 other than ^U, that character is used instead of ^U.
1041 .IP "^G"
1042 Delete the entire command line and return to the main prompt.
1043
1044 .SH "KEY BINDINGS"
1045 You may define your own
1046 .I less
1047 commands by using the program
1048 .I lesskey
1049 (1)
1050 to create a lesskey file.
1051 This file specifies a set of command keys and an action
1052 associated with each key.
1053 You may also use
1054 .I lesskey
1055 to change the line-editing keys (see LINE EDITING),
1056 and to set environment variables.
1057 If the environment variable LESSKEY is set,
1058 .I less
1059 uses that as the name of the lesskey file.
1060 Otherwise,
1061 .I less
1062 looks in a standard place for the lesskey file:
1063 On Unix systems,
1064 .I less
1065 looks for a lesskey file called "$HOME/.less".
1066 On MS-DOS and Windows systems,
1067 .I less
1068 looks for a lesskey file called "$HOME/_less", and if it is not found there,
1069 then looks for a lesskey file called "_less" in any directory specified
1070 in the PATH environment variable.
1071 On OS/2 systems,
1072 .I less
1073 looks for a lesskey file called "$HOME/less.ini", and if it is not found,
1074 then looks for a lesskey file called "less.ini" in any directory specified
1075 in the INIT environment variable, and if it not found there,
1076 then looks for a lesskey file called "less.ini" in any directory specified
1077 in the PATH environment variable.
1078 See the
1079 .I lesskey
1080 manual page for more details.
1081 .P
1082 A system-wide lesskey file may also be set up to provide key bindings.
1083 If a key is defined in both a local lesskey file and in the
1084 system-wide file, key bindings in the local file take precedence over
1085 those in the system-wide file.
1086 If the environment variable LESSKEY_SYSTEM is set,
1087 .I less
1088 uses that as the name of the system-wide lesskey file.
1089 Otherwise,
1090 .I less
1091 looks in a standard place for the system-wide lesskey file:
1092 On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless.
1093 (However, if
1094 .I less
1095 was built with a different sysconf directory than /usr/local/etc,
1096 that directory is where the sysless file is found.)
1097 On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless.
1098 On OS/2 systems, the system-wide lesskey file is c:\esysless.ini.
1099
1100 .SH "INPUT PREPROCESSOR"
1101 You may define an "input preprocessor" for
1102 .IR less .
1103 Before
1104 .I less
1105 opens a file, it first gives your input preprocessor a chance to modify the
1106 way the contents of the file are displayed.
1107 An input preprocessor is simply an executable program (or shell script),
1108 which writes the contents of the file to a different file,
1109 called the replacement file.
1110 The contents of the replacement file are then displayed
1111 in place of the contents of the original file.
1112 However, it will appear to the user as if the original file is opened;
1113 that is,
1114 .I less
1115 will display the original filename as the name of the current file.
1116 .PP
1117 An input preprocessor receives one command line argument, the original filename,
1118 as entered by the user.
1119 It should create the replacement file, and when finished,
1120 print the name of the replacement file to its standard output.
1121 If the input preprocessor does not output a replacement filename,
1122 .I less
1123 uses the original file, as normal.
1124 The input preprocessor is not called when viewing standard input.
1125 To set up an input preprocessor, set the LESSOPEN environment variable
1126 to a command line which will invoke your input preprocessor.
1127 This command line should include one occurrence of the string "%s",
1128 which will be replaced by the filename
1129 when the input preprocessor command is invoked.
1130 .PP
1131 When
1132 .I less
1133 closes a file opened in such a way, it will call another program,
1134 called the input postprocessor,
1135 which may perform any desired clean-up action (such as deleting the
1136 replacement file created by LESSOPEN).
1137 This program receives two command line arguments, the original filename
1138 as entered by the user, and the name of the replacement file.
1139 To set up an input postprocessor, set the LESSCLOSE environment variable
1140 to a command line which will invoke your input postprocessor.
1141 It may include two occurrences of the string "%s";
1142 the first is replaced with the original name of the file and
1143 the second with the name of the replacement file,
1144 which was output by LESSOPEN.
1145 .PP
1146 For example, on many Unix systems, these two scripts will allow you
1147 to keep files in compressed format, but still let
1148 .I less
1149 view them directly:
1150 .PP
1151 lessopen.sh:
1152 .br
1153         #! /bin/sh
1154 .br
1155         case "$1" in
1156 .br
1157         *.Z)    uncompress \-c $1  >/tmp/less.$$  2>/dev/null
1158 .br
1159                 if [ \-s /tmp/less.$$ ]; then
1160 .br
1161                         echo /tmp/less.$$
1162 .br
1163                 else
1164 .br
1165                         rm \-f /tmp/less.$$
1166 .br
1167                 fi
1168 .br
1169                 ;;
1170 .br
1171         esac
1172 .PP
1173 lessclose.sh:
1174 .br
1175         #! /bin/sh
1176 .br
1177         rm $2
1178 .PP
1179 To use these scripts, put them both where they can be executed and
1180 set LESSOPEN="lessopen.sh\ %s", and
1181 LESSCLOSE="lessclose.sh\ %s\ %s".
1182 More complex LESSOPEN and LESSCLOSE scripts may be written
1183 to accept other types of compressed files, and so on.
1184 .PP
1185 It is also possible to set up an input preprocessor to
1186 pipe the file data directly to
1187 .IR less ,
1188 rather than putting the data into a replacement file.
1189 This avoids the need to decompress the entire file before
1190 starting to view it.
1191 An input preprocessor that works this way is called an input pipe.
1192 An input pipe, instead of writing the name of a replacement file on
1193 its standard output,
1194 writes the entire contents of the replacement file on its standard output.
1195 If the input pipe does not write any characters on its standard output,
1196 then there is no replacement file and
1197 .I less
1198 uses the original file, as normal.
1199 To use an input pipe,
1200 make the first character in the LESSOPEN environment variable a
1201 vertical bar (|) to signify that the input preprocessor is an input pipe.
1202 As with non-pipe input preprocessors, the command string must contain one
1203 occurrence of %s, which is replaced with the filename of the input file.
1204 .PP
1205 For example, on many Unix systems, this script will work like the
1206 previous example scripts:
1207 .PP
1208 lesspipe.sh:
1209 .br
1210         #! /bin/sh
1211 .br
1212         case "$1" in
1213 .br
1214         *.Z)    uncompress \-c $1  2>/dev/null
1215 .br
1216         *)      exit 1
1217 .br
1218                 ;;
1219 .br
1220         esac
1221 .br
1222         exit $?
1223 .br
1224 .PP
1225 To use this script, put it where it can be executed and set
1226 LESSOPEN="|lesspipe.sh %s".
1227 .PP
1228 Note that a preprocessor cannot output an empty file, since that
1229 is interpreted as meaning there is no replacement, and
1230 the original file is used.
1231 To avoid this, if LESSOPEN starts with two vertical bars,
1232 the exit status of the script becomes meaningful.
1233 If the exit status is zero, the output is considered to be
1234 replacement text, even if it is empty.
1235 If the exit status is nonzero, any output is ignored and the
1236 original file is used.
1237 For compatibility with previous versions of
1238 .IR less ,
1239 if LESSOPEN starts with only one vertical bar, the exit status
1240 of the preprocessor is ignored.
1241 .PP
1242 When an input pipe is used, a LESSCLOSE postprocessor can be used,
1243 but it is usually not necessary since there is no replacement file
1244 to clean up.
1245 In this case, the replacement file name passed to the LESSCLOSE
1246 postprocessor is "\-".
1247 .PP
1248 For compatibility with previous versions of
1249 .IR less ,
1250 the input preprocessor or pipe is not used if
1251 .I less
1252 is viewing standard input.
1253 However, if the first character of LESSOPEN is a dash (\-),
1254 the input preprocessor is used on standard input as well as other files.
1255 In this case, the dash is not considered to be part of
1256 the preprocessor command.
1257 If standard input is being viewed, the input preprocessor is passed
1258 a file name consisting of a single dash.
1259 Similarly, if the first two characters of LESSOPEN are vertical bar and dash
1260 (|\-) or two vertical bars and a dash (||\-),
1261 the input pipe is used on standard input as well as other files.
1262 Again, in this case the dash is not considered to be part of
1263 the input pipe command.
1264
1265 .SH "NATIONAL CHARACTER SETS"
1266 There are three types of characters in the input file:
1267 .IP "normal characters"
1268 can be displayed directly to the screen.
1269 .IP "control characters"
1270 should not be displayed directly, but are expected to be found
1271 in ordinary text files (such as backspace and tab).
1272 .IP "binary characters"
1273 should not be displayed directly and are not expected to be found
1274 in text files.
1275 .PP
1276 A "character set" is simply a description of which characters are to
1277 be considered normal, control, and binary.
1278 The LESSCHARSET environment variable may be used to select a character set.
1279 Possible values for LESSCHARSET are:
1280 .IP ascii
1281 BS, TAB, NL, CR, and formfeed are control characters,
1282 all chars with values between 32 and 126 are normal,
1283 and all others are binary.
1284 .IP iso8859
1285 Selects an ISO 8859 character set.
1286 This is the same as ASCII, except characters between 160 and 255 are
1287 treated as normal characters.
1288 .IP latin1
1289 Same as iso8859.
1290 .IP latin9
1291 Same as iso8859.
1292 .IP dos
1293 Selects a character set appropriate for MS-DOS.
1294 .IP ebcdic
1295 Selects an EBCDIC character set.
1296 .IP IBM-1047
1297 Selects an EBCDIC character set used by OS/390 Unix Services.
1298 This is the EBCDIC analogue of latin1.  You get similar results
1299 by setting either LESSCHARSET=IBM-1047 or LC_CTYPE=en_US
1300 in your environment.
1301 .IP koi8-r
1302 Selects a Russian character set.
1303 .IP next
1304 Selects a character set appropriate for NeXT computers.
1305 .IP utf-8
1306 Selects the UTF-8 encoding of the ISO 10646 character set.
1307 UTF-8 is special in that it supports multi-byte characters in the input file.
1308 It is the only character set that supports multi-byte characters.
1309 .IP windows
1310 Selects a character set appropriate for Microsoft Windows (cp 1251).
1311 .PP
1312 In rare cases, it may be desired to tailor
1313 .I less
1314 to use a character set other than the ones definable by LESSCHARSET.
1315 In this case, the environment variable LESSCHARDEF can be used
1316 to define a character set.
1317 It should be set to a string where each character in the string represents
1318 one character in the character set.
1319 The character "." is used for a normal character, "c" for control,
1320 and "b" for binary.
1321 A decimal number may be used for repetition.
1322 For example, "bccc4b.\&" would mean character 0 is binary,
1323 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
1324 All characters after the last are taken to be the same as the last,
1325 so characters 9 through 255 would be normal.
1326 (This is an example, and does not necessarily
1327 represent any real character set.)
1328 .PP
1329 This table shows the value of LESSCHARDEF which is equivalent
1330 to each of the possible values for LESSCHARSET:
1331 .sp
1332         ascii\  8bcccbcc18b95.b
1333 .br
1334         dos\ \ \        8bcccbcc12bc5b95.b.
1335 .br
1336         ebcdic  5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
1337 .br
1338         \ \ \ \ \ \     9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
1339 .br
1340         IBM-1047        4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
1341 .br
1342         \ \ \ \ \ \     191.b
1343 .br
1344         iso8859 8bcccbcc18b95.33b.
1345 .br
1346         koi8-r  8bcccbcc18b95.b128.
1347 .br
1348         latin1  8bcccbcc18b95.33b.
1349 .br
1350         next\ \         8bcccbcc18b95.bb125.bb
1351 .PP
1352 If neither LESSCHARSET nor LESSCHARDEF is set,
1353 but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8"
1354 is found in the LC_ALL, LC_CTYPE or LANG
1355 environment variables, then the default character set is utf-8.
1356 .PP
1357 If that string is not found, but your system supports the
1358 .I setlocale
1359 interface,
1360 .I less
1361 will use setlocale to determine the character set.
1362 setlocale is controlled by setting the LANG or LC_CTYPE environment
1363 variables.
1364 .PP
1365 Finally, if the
1366 .I setlocale
1367 interface is also not available, the default character set is latin1.
1368 .PP
1369 Control and binary characters are displayed in standout (reverse video).
1370 Each such character is displayed in caret notation if possible
1371 (e.g.\& ^A for control-A).  Caret notation is used only if
1372 inverting the 0100 bit results in a normal printable character.
1373 Otherwise, the character is displayed as a hex number in angle brackets.
1374 This format can be changed by
1375 setting the LESSBINFMT environment variable.
1376 LESSBINFMT may begin with a "*" and one character to select
1377 the display attribute:
1378 "*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout,
1379 and "*n" is normal.
1380 If LESSBINFMT does not begin with a "*", normal attribute is assumed.
1381 The remainder of LESSBINFMT is a string which may include one
1382 printf-style escape sequence (a % followed by x, X, o, d, etc.).
1383 For example, if LESSBINFMT is "*u[%x]", binary characters
1384 are displayed in underlined hexadecimal surrounded by brackets.
1385 The default if no LESSBINFMT is specified is "*s<%02X>".
1386 Warning: the result of expanding the character via LESSBINFMT must
1387 be less than 31 characters.
1388 .PP
1389 When the character set is utf-8, the LESSUTFBINFMT environment variable
1390 acts similarly to LESSBINFMT but it applies to Unicode code points
1391 that were successfully decoded but are unsuitable for display (e.g.,
1392 unassigned code points).
1393 Its default value is "<U+%04lX>".
1394 Note that LESSUTFBINFMT and LESSBINFMT share their display attribute
1395 setting ("*x") so specifying one will affect both;
1396 LESSUTFBINFMT is read after LESSBINFMT so its setting, if any,
1397 will have priority.
1398 Problematic octets in a UTF-8 file (octets of a truncated sequence,
1399 octets of a complete but non-shortest form sequence, illegal octets,
1400 and stray trailing octets)
1401 are displayed individually using LESSBINFMT so as to facilitate diagnostic
1402 of how the UTF-8 file is ill-formed.
1403
1404 .SH "PROMPTS"
1405 The \-P option allows you to tailor the prompt to your preference.
1406 The string given to the \-P option replaces the specified prompt string.
1407 Certain characters in the string are interpreted specially.
1408 The prompt mechanism is rather complicated to provide flexibility,
1409 but the ordinary user need not understand the details of constructing
1410 personalized prompt strings.
1411 .sp
1412 A percent sign followed by a single character is expanded
1413 according to what the following character is:
1414 .IP "%b\fIX\fP"
1415 Replaced by the byte offset into the current input file.
1416 The b is followed by a single character (shown as \fIX\fP above)
1417 which specifies the line whose byte offset is to be used.
1418 If the character is a "t", the byte offset of the top line in the
1419 display is used,
1420 an "m" means use the middle line,
1421 a "b" means use the bottom line,
1422 a "B" means use the line just after the bottom line,
1423 and a "j" means use the "target" line, as specified by the \-j option.
1424 .IP "%B"
1425 Replaced by the size of the current input file.
1426 .IP "%c"
1427 Replaced by the column number of the text appearing in the first
1428 column of the screen.
1429 .IP "%d\fIX\fP"
1430 Replaced by the page number of a line in the input file.
1431 The line to be used is determined by the \fIX\fP, as with the %b option.
1432 .IP "%D"
1433 Replaced by the number of pages in the input file,
1434 or equivalently, the page number of the last line in the input file.
1435 .IP "%E"
1436 Replaced by the name of the editor (from the VISUAL environment variable,
1437 or the EDITOR environment variable if VISUAL is not defined).
1438 See the discussion of the LESSEDIT feature below.
1439 .IP "%f"
1440 Replaced by the name of the current input file.
1441 .IP "%F"
1442 Replaced by the last component of the name of the current input file.
1443 .IP "%i"
1444 Replaced by the index of the current file in the list of
1445 input files.
1446 .IP "%l\fIX\fP"
1447 Replaced by the line number of a line in the input file.
1448 The line to be used is determined by the \fIX\fP, as with the %b option.
1449 .IP "%L"
1450 Replaced by the line number of the last line in the input file.
1451 .IP "%m"
1452 Replaced by the total number of input files.
1453 .IP "%p\fIX\fP"
1454 Replaced by the percent into the current input file, based on byte offsets.
1455 The line used is determined by the \fIX\fP as with the %b option.
1456 .IP "%P\fIX\fP"
1457 Replaced by the percent into the current input file, based on line numbers.
1458 The line used is determined by the \fIX\fP as with the %b option.
1459 .IP "%s"
1460 Same as %B.
1461 .IP "%t"
1462 Causes any trailing spaces to be removed.
1463 Usually used at the end of the string, but may appear anywhere.
1464 .IP "%T"
1465 Normally expands to the word "file".
1466 However if viewing files via a tags list using the \-t option, it expands to the word "tag".
1467 .IP "%x"
1468 Replaced by the name of the next input file in the list.
1469 .PP
1470 If any item is unknown (for example, the file size if input
1471 is a pipe), a question mark is printed instead.
1472 .PP
1473 The format of the prompt string can be changed
1474 depending on certain conditions.
1475 A question mark followed by a single character acts like an "IF":
1476 depending on the following character, a condition is evaluated.
1477 If the condition is true, any characters following the question mark
1478 and condition character, up to a period, are included in the prompt.
1479 If the condition is false, such characters are not included.
1480 A colon appearing between the question mark and the
1481 period can be used to establish an "ELSE": any characters between
1482 the colon and the period are included in the string if and only if
1483 the IF condition is false.
1484 Condition characters (which follow a question mark) may be:
1485 .IP "?a"
1486 True if any characters have been included in the prompt so far.
1487 .IP "?b\fIX\fP"
1488 True if the byte offset of the specified line is known.
1489 .IP "?B"
1490 True if the size of current input file is known.
1491 .IP "?c"
1492 True if the text is horizontally shifted (%c is not zero).
1493 .IP "?d\fIX\fP"
1494 True if the page number of the specified line is known.
1495 .IP "?e"
1496 True if at end-of-file.
1497 .IP "?f"
1498 True if there is an input filename
1499 (that is, if input is not a pipe).
1500 .IP "?l\fIX\fP"
1501 True if the line number of the specified line is known.
1502 .IP "?L"
1503 True if the line number of the last line in the file is known.
1504 .IP "?m"
1505 True if there is more than one input file.
1506 .IP "?n"
1507 True if this is the first prompt in a new input file.
1508 .IP "?p\fIX\fP"
1509 True if the percent into the current input file, based on byte offsets,
1510 of the specified line is known.
1511 .IP "?P\fIX\fP"
1512 True if the percent into the current input file, based on line numbers,
1513 of the specified line is known.
1514 .IP "?s"
1515 Same as "?B".
1516 .IP "?x"
1517 True if there is a next input file
1518 (that is, if the current input file is not the last one).
1519 .PP
1520 Any characters other than the special ones
1521 (question mark, colon, period, percent, and backslash)
1522 become literally part of the prompt.
1523 Any of the special characters may be included in the prompt literally
1524 by preceding it with a backslash.
1525 .PP
1526 Some examples:
1527 .sp
1528 ?f%f:Standard input.
1529 .sp
1530 This prompt prints the filename, if known;
1531 otherwise the string "Standard input".
1532 .sp
1533 ?f%f \&.?ltLine %lt:?pt%pt\e%:?btByte %bt:-...
1534 .sp
1535 This prompt would print the filename, if known.
1536 The filename is followed by the line number, if known,
1537 otherwise the percent if known, otherwise the byte offset if known.
1538 Otherwise, a dash is printed.
1539 Notice how each question mark has a matching period,
1540 and how the % after the %pt
1541 is included literally by escaping it with a backslash.
1542 .sp
1543 ?n?f%f\ .?m(%T %i of %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t";
1544 .sp
1545 This prints the filename if this is the first prompt in a file,
1546 followed by the "file N of N" message if there is more
1547 than one input file.
1548 Then, if we are at end-of-file, the string "(END)" is printed
1549 followed by the name of the next file, if there is one.
1550 Finally, any trailing spaces are truncated.
1551 This is the default prompt.
1552 For reference, here are the defaults for
1553 the other two prompts (\-m and \-M respectively).
1554 Each is broken into two lines here for readability only.
1555 .nf
1556 .sp
1557 ?n?f%f\ .?m(%T\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.:
1558         ?pB%pB\e%:byte\ %bB?s/%s...%t
1559 .sp
1560 ?f%f\ .?n?m(%T\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ :
1561         byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\e:\ %x.:?pB%pB\e%..%t
1562 .sp
1563 .fi
1564 And here is the default message produced by the = command:
1565 .nf
1566 .sp
1567 ?f%f\ .?m(%T\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ .
1568         byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\e%..%t
1569 .fi
1570 .PP
1571 The prompt expansion features are also used for another purpose:
1572 if an environment variable LESSEDIT is defined, it is used
1573 as the command to be executed when the v command is invoked.
1574 The LESSEDIT string is expanded in the same way as the prompt strings.
1575 The default value for LESSEDIT is:
1576 .nf
1577 .sp
1578         %E\ ?lm+%lm.\ %f
1579 .sp
1580 .fi
1581 Note that this expands to the editor name, followed by a + and the
1582 line number, followed by the file name.
1583 If your editor does not accept the "+linenumber" syntax, or has other
1584 differences in invocation syntax, the LESSEDIT variable can be
1585 changed to modify this default.
1586
1587 .SH SECURITY
1588 When the environment variable LESSSECURE is set to 1,
1589 .I less
1590 runs in a "secure" mode.
1591 This means these features are disabled:
1592 .RS
1593 .IP "!"
1594 the shell command
1595 .IP "|"
1596 the pipe command
1597 .IP ":e"
1598 the examine command.
1599 .IP "v"
1600 the editing command
1601 .IP "s  \-o"
1602 log files
1603 .IP "\-k"
1604 use of lesskey files
1605 .IP "\-t"
1606 use of tags files
1607 .IP " "
1608 metacharacters in filenames, such as *
1609 .IP " "
1610 filename completion (TAB, ^L)
1611 .RE
1612 .PP
1613 Less can also be compiled to be permanently in "secure" mode.
1614
1615 .SH "COMPATIBILITY WITH MORE"
1616 If the environment variable LESS_IS_MORE is set to 1,
1617 or if the program is invoked via a file link named "more",
1618 .I less
1619 behaves (mostly) in conformance with the POSIX "more" command specification.
1620 In this mode, less behaves differently in these ways:
1621 .PP
1622 The \-e option works differently.
1623 If the \-e option is not set,
1624 .I less
1625 behaves as if the \-e option were set.
1626 If the \-e option is set,
1627 .I less
1628 behaves as if the \-E option were set.
1629 .PP
1630 The \-m option works differently.
1631 If the \-m option is not set, the medium prompt is used,
1632 and it is prefixed with the string "--More--".
1633 If the \-m option is set, the short prompt is used.
1634 .PP
1635 The \-n option acts like the \-z option.
1636 The normal behavior of the \-n option is unavailable in this mode.
1637 .PP
1638 The parameter to the \-p option is taken to be a
1639 .I less
1640 command rather than a search pattern.
1641 .PP
1642 The LESS environment variable is ignored,
1643 and the MORE environment variable is used in its place.
1644
1645 .SH "ENVIRONMENT VARIABLES"
1646 Environment variables may be specified either in the system environment
1647 as usual, or in a
1648 .I lesskey
1649 (1) file.
1650 If environment variables are defined in more than one place,
1651 variables defined in a local lesskey file take precedence over
1652 variables defined in the system environment, which take precedence
1653 over variables defined in the system-wide lesskey file.
1654 .IP COLUMNS
1655 Sets the number of columns on the screen.
1656 Takes precedence over the number of columns specified by the TERM variable.
1657 (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1658 the window system's idea of the screen size takes precedence over the
1659 LINES and COLUMNS environment variables.)
1660 .IP EDITOR
1661 The name of the editor (used for the v command).
1662 .IP HOME
1663 Name of the user's home directory
1664 (used to find a lesskey file on Unix and OS/2 systems).
1665 .IP "HOMEDRIVE, HOMEPATH"
1666 Concatenation of the HOMEDRIVE and HOMEPATH environment variables is
1667 the name of the user's home directory if the HOME variable is not set
1668 (only in the Windows version).
1669 .IP INIT
1670 Name of the user's init directory (used to find a lesskey file on OS/2 systems).
1671 .IP LANG
1672 Language for determining the character set.
1673 .IP LC_CTYPE
1674 Language for determining the character set.
1675 .IP LESS
1676 Options which are passed to
1677 .I less
1678 automatically.
1679 .IP LESSANSIENDCHARS
1680 Characters which may end an ANSI color escape sequence
1681 (default "m").
1682 .IP LESSANSIMIDCHARS
1683 Characters which may appear between the ESC character and the
1684 end character in an ANSI color escape sequence
1685 (default "0123456789:;[?!"'#%()*+\ ".
1686 .IP LESSBINFMT
1687 Format for displaying non-printable, non-control characters.
1688 .IP LESSCHARDEF
1689 Defines a character set.
1690 .IP LESSCHARSET
1691 Selects a predefined character set.
1692 .IP LESSCLOSE
1693 Command line to invoke the (optional) input-postprocessor.
1694 .IP LESSECHO
1695 Name of the lessecho program (default "lessecho").
1696 The lessecho program is needed to expand metacharacters, such as * and ?,
1697 in filenames on Unix systems.
1698 .IP LESSEDIT
1699 Editor prototype string (used for the v command).
1700 See discussion under PROMPTS.
1701 .IP LESSGLOBALTAGS
1702 Name of the command used by the \-t option to find global tags.
1703 Normally should be set to "global" if your system has the
1704 .I global
1705 (1) command.  If not set, global tags are not used.
1706 .IP LESSHISTFILE
1707 Name of the history file used to remember search commands and
1708 shell commands between invocations of
1709 .IR less .
1710 If set to "\-" or "/dev/null", a history file is not used.
1711 The default is "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on
1712 DOS and Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini"
1713 on OS/2 systems.
1714 .IP LESSHISTSIZE
1715 The maximum number of commands to save in the history file.
1716 The default is 100.
1717 .IP LESSKEY
1718 Name of the default lesskey(1) file.
1719 .IP LESSKEY_SYSTEM
1720 Name of the default system-wide lesskey(1) file.
1721 .IP LESSMETACHARS
1722 List of characters which are considered "metacharacters" by the shell.
1723 .IP LESSMETAESCAPE
1724 Prefix which less will add before each metacharacter in a
1725 command sent to the shell.
1726 If LESSMETAESCAPE is an empty string, commands containing
1727 metacharacters will not be passed to the shell.
1728 .IP LESSOPEN
1729 Command line to invoke the (optional) input-preprocessor.
1730 .IP LESSSECURE
1731 Runs less in "secure" mode.
1732 See discussion under SECURITY.
1733 .IP LESSSEPARATOR
1734 String to be appended to a directory name in filename completion.
1735 .IP LESSUTFBINFMT
1736 Format for displaying non-printable Unicode code points.
1737 .IP LESS_IS_MORE
1738 Emulate the
1739 .I more
1740 (1) command.
1741 .IP LINES
1742 Sets the number of lines on the screen.
1743 Takes precedence over the number of lines specified by the TERM variable.
1744 (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1745 the window system's idea of the screen size takes precedence over the
1746 LINES and COLUMNS environment variables.)
1747 .IP MORE
1748 Options which are passed to
1749 .I less
1750 automatically when running in
1751 .I more
1752 compatible mode.
1753 .IP PATH
1754 User's search path (used to find a lesskey file
1755 on MS-DOS and OS/2 systems).
1756 .IP SHELL
1757 The shell used to execute the ! command, as well as to expand filenames.
1758 .IP TERM
1759 The type of terminal on which
1760 .I less
1761 is being run.
1762 .IP VISUAL
1763 The name of the editor (used for the v command).
1764
1765 .SH "SEE ALSO"
1766 lesskey(1)
1767
1768 .SH COPYRIGHT
1769 Copyright (C) 1984-2017  Mark Nudelman
1770 .PP
1771 less is part of the GNU project and is free software.
1772 You can redistribute it and/or modify it
1773 under the terms of either
1774 (1) the GNU General Public License as published by
1775 the Free Software Foundation; or (2) the Less License.
1776 See the file README in the less distribution for more details
1777 regarding redistribution.
1778 You should have received a copy of the GNU General Public License
1779 along with the source for less; see the file COPYING.
1780 If not, write to the Free Software Foundation, 59 Temple Place,
1781 Suite 330, Boston, MA  02111-1307, USA.
1782 You should also have received a copy of the Less License;
1783 see the file LICENSE.
1784 .PP
1785 less is distributed in the hope that it will be useful, but
1786 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1787 or FITNESS FOR A PARTICULAR PURPOSE.
1788 See the GNU General Public License for more details.
1789
1790 .SH AUTHOR
1791 .PP
1792 Mark Nudelman
1793 .br
1794 Send bug reports or comments to <bug-less@gnu.org>
1795 .br
1796 See http://www.greenwoodsoftware.com/less/bugs.html for the latest list of known bugs in less.
1797 .br
1798 For more information, see the less homepage at
1799 .br
1800 http://www.greenwoodsoftware.com/less.