Back to the command reference

less

FilesBeginner In simulator In real Linux

View a file page by page, with scrolling and search

Name: less: more than more ("less is more")

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

less is a pager: it shows a file one screen at a time and lets you scroll back and forth and search. It doesn't read the whole file first, so even huge files open instantly.

Keys: space next page, b back, / search, n next match, g/G start/end, q quit. man usually displays pages through less.

Syntax

less [OPTION]... FILE...

Common options

-NShow line numbers
-SChop long lines instead of wrapping
-iSearches ignore case (unless they contain capitals)
-RShow colours properly (output of grep --color=always, say)
-FQuit at once if the text fits on one screen
-XLeave the text on the screen after quitting
+FFollow the end like tail -f (Ctrl+C stops following)
/text(inside less) Search for text; n for the next match
?textSearch backwards for text
n / NNext / previous match
g / GGo to the start / the end
q(inside less) Quit

Examples

  • $ less /var/log/syslog

    Page through a log

    Explain
  • $ ps -ef | less

    Page through long output

    Explain

Related