less file ...
less
command takes a list of file names for its arguments and displays its contents screen by screen.q
to quit.e
to scroll forward one line.y
to scroll backward one line.f
to scroll forward one window (or press the spacebar).b
to scroll backward one window.d
to scroll forward one half-window.u
to scroll backward one half-window.g
to jump to first line in the current file.G
to jump to last line in current file.:n
to move to the next file ().:q
to move to the previous file.Ctrl+g
(or Ctrl+G
) to show the current file name, start/end number of lines shown, bytes read, and percentage of data shown.
Example : file1 lines 52-102/118 byte 6992/8145 85% (press RETURN)$ less file1 file2 file3
enter <control> n |Scroll forward {n} lines, default 1 line. |The entire {n} lines are displayed, even if {n} is more than the screen size. y k |Scroll backward {n} lines, default 1 line. |The entire {n} lines are displayed, even if {n} is more than the screen size. #-- ------------------------------------ d <control> d |Scroll forward {n} lines, default one half of the screen size. |If {n} is specified, it becomes the new default for subsequent "d" and "u" commands. u <control> u |Scroll backward {n} lines, default one half of the screen size. |If {n} is specified, it becomes the new default for subsequent "d" and "u" commands. #-- ------------------------------------ f <spacebar> |Scroll forward {n} lines, default one window. |If {n} is more than the screen size, only the final screen is displayed. b <control> b |Scroll backward {n} lines, default one window. |If {n} is more than the screen size, only the final screenful is displayed. #-- ------------------------------------ g < |Go to line {n} in the file, default the beginning of the file. G > |Go to line {n} in the file, default the end of the file. #-- ------------------------------------ m |Followed by any lower-case letter, marks the current position with that letter. ' |(Single quote) |Followed by any lower-case letter, returns to the position which was previously marked with that letter. |Followed by the character "^" jumps to the beginning of the file. |Followed by the character "$" jumps to the end of the file. #-- ------------------------------------ :n |Go to the next file (from the list of files given in the command line). |If a number {n} is specified, the {n}-th next file is examined. :p |Go to the previous file in the command line list. |If a number {n} is specified, the {n}-th previous file is examined. :x |Go to the first file in the command line list. |If a number {n} is specified, the {n}-th file in the list is examined. :d |Remove the current file from the list of files. q Q :q :Q ZZ |Exits less.
/pattern |Search forward in the file for the {n}-th line containing the pattern. |{n} defaults to 1. ?pattern |Search backward in the file for the {n}-th line containing the pattern. |The search starts at the line immediately before the top line displayed. &pattern |Display only lines which match the pattern; lines which do not match the pattern are not displayed. |If you type "&" followed by <enter>, any filtering is turned off, and all lines are displayed. |While filtering is in effect, an "&" is displayed at the beginning of the prompt, as a reminder that some lines in the file may be hidden. n |Repeat previous search, for {n}-th line containing the last pattern. |If the previous search was modified by "<control> N", the search is made for the {n}-th line NOT containing the pattern. |If the previous search was modified by "<control> E", the search continues in the next (or previous) file if not satisfied in the current file. N |Repeat previous search, but in the reverse direction.
<control> N ! |Search for lines which do NOT match the pattern. <control> E * |Search multiple files. |That is, if the search reaches the END/beginning of the current file without finding a match, |the search continues in the next/previous file in the command line list. <control> F @ |Begin the search at the first/last line of the first/last file in the command line list, |regardless of what is currently displayed on the screen or the settings of the -a or -j options. <control> K |Highlight any text which matches the pattern on the current screen, but don't move to the first match (KEEP current position).