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