Text
less
View text files page by page with search and scrolling.
textpagerviewsearchscroll
Additional Notes
less is a pager for reading text. It opens file or command output in an interactive viewer where you can scroll, search, and quit without printing the whole file into the terminal.
Despite the name, less is more capable than more.
Syntax
less [options] file...
command | less
Parameters
options: Flags that change howlessbehaves.file: Text file to read or process.
Common Keys
q: Quit.Space: Next page.b: Previous page.Enter: Move down one line./pattern: Search forward.?pattern: Search backward.n: Next search match.N: Previous search match.g: Go to beginning.G: Go to end.F: Follow new data, similar totail -f.
Common Options
-N: Show line numbers.-S: Chop long lines instead of wrapping.-R: Show raw ANSI colors.+G: Start at the end of the file.
Examples
less /var/log/syslog
Open a log file.
less -N script.sh
View a file with line numbers.
grep -r "error" . | less
Read long command output in a pager.
less +G app.log
Open a file at the end.
Practical Notes
lessdoes not edit files.- Use search inside
lessinstead of repeatedly runninggrepfor simple reading. - Press
hinsidelessfor help. - Many commands use
lessautomatically as their pager.