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