Skip to content

less

12 commands

A pager for viewing large files and command output one screen at a time, with search and follow mode.

  • pager
  • text

Install less

sudo apt install less

Opening6

less <file>

Opens a file in a scrollable pager without loading it all into memory.

Link
less -N <file>

Shows line numbers.

Link
less -S <file>

Chops long lines instead of wrapping — scroll sideways with the arrow keys.

Link
less +F <file>

Follows the file like tail -f. Press Ctrl-C to stop following and F to resume.

Link
less -R <file>

Displays ANSI colour codes correctly.

Link
<command> | less

Pages through the output of any command.

Link

Inside less6

/<pattern>

Searches forward; press n for the next match and N for the previous.

Link
?<pattern>

Searches backward.

Link
&<pattern>

Shows only lines matching the pattern; & with no pattern clears the filter.

Link
g / G

Jumps to the start (g) or end (G) of the file.

Link
<n>g

Jumps to line n.

Link