less: a file viewer
less opens a file one screen at a time, and lets you scroll and search. It takes over the whole terminal until you press q:
less numbers.txtYou already know these keys: man uses less to show manual pages.
| Keys | What it does |
|---|---|
| Space | Next page |
| b | Previous page |
| ↓ / ↑ | One line down / up |
| g | Go to the first line |
| G | Go to the last line |
| /word | Search forward for word (press Enter) |
| ?word | Search backward |
| n / N | Next / previous match |
| q | Quit |
Useful options
| Command | What it does |
|---|---|
less -N file | Show line numbers |
less +G file | Open at the end of the file (handy for logs) |
less -S file | Don't wrap long lines; scroll sideways with ← and → |
Tip:
moreis an older, simpler viewer that can only go forward. less is more, as the joke goes.
Remember:
less file, then Space/b to page,/to search,qto quit.