Name
less [options
] [files
] — less
Synopsis
/usr/bin
stdin stdout[9] - file -- opt --help --version
Use less
to view text one page at a time (or one window or screenful at a time). It’s great for text files, or as the final command in a shell pipeline with lengthy output.
$ command1 | command2 | command3 | command4 | less
While running less
, type h
for a help message describing all its features. Here are some useful keystrokes for paging through files.
Keystroke | Meaning |
| View a help page. |
Spacebar, | Move forward one screenful. |
Enter | Move forward one line. |
| Move backward one screenful. |
| Enter search mode. Follow it with a regular expression and press Enter, and |
| Same as |
| Repeat your most recent search forward. |
N | Repeat your most recent search backward. |
v | Edit the current file with your default text editor (the value of environment variable |
< | Jump to beginning of file. |
> | Jump to end of file. |
:n | Jump to next file. |
:p | Jump to previous file. |
less
has a mind-boggling number of features; we’re presenting only the most common. The manpage is recommended reading.
Useful options | |
| Clear the screen before displaying the next page. |
| Print a more verbose prompt, displaying the percentage of the file displayed so far. |
| Prepend line numbers to the output. |
| Display control characters literally; normally |
| Squeeze ... |
Get Linux Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.