less
text_processingLinux/Unix/macOS
The less command is one of the most frequently used commands in Linux/Unix-like operating systems. less File pager that allows backward and forward navigation through file contents
Quick Reference
Command Name:
less
Category:
text_processing
Platform:
Linux/Unix/macOS
Basic Usage:
less [options] [arguments]
Common Use Cases
Syntax
less [options] file...
Options
Option | Description |
---|---|
-? or --help |
Display help |
-a or --search-skip-screen |
Search skips current screen |
-b N or --buffers=N |
Set buffer size |
-B or --auto-buffers |
Don't automatically allocate buffers for pipes |
-c or --clear-screen |
Repaint by clearing rather than scrolling |
-d or --dumb |
Suppress error messages about terminal capabilities |
-e or --quit-at-eof |
Exit automatically when reaching end of file |
-E or --QUIT-AT-EOF |
Exit automatically after reaching EOF twice |
-f or --force |
Force opening non-regular files |
-F or --quit-if-one-screen |
Exit if entire file fits on first screen |
-g or --hilite-search |
Highlight only the current match of a search pattern |
-G or --HILITE-SEARCH |
Don't highlight any matches of a search pattern |
-i or --ignore-case |
Ignore case in searches that do not contain uppercase |
-I or --IGNORE-CASE |
Ignore case in all searches |
-j N or --jump-target=N |
Position target line on screen |
-J or --status-column |
Display a status column on the left |
-k file or --lesskey-file=file |
Use a lesskey file |
-K or --quit-on-intr |
Exit less on interrupt |
-L or --no-lessopen |
Don't use the LESSOPEN preprocessor |
-m or --long-prompt |
Show detailed prompt |
-M or --LONG-PROMPT |
Show even more detailed prompt |
-n or --line-numbers |
Don't use line numbers |
-N or --LINE-NUMBERS |
Display line numbers |
-o file or --log-file=file |
Copy input to file |
-O file or --LOG-FILE=file |
Copy input to file (unconditionally overwrite) |
-p pattern or --pattern=pattern |
Start at pattern |
-P prompt or --prompt=prompt |
Define new prompt |
-q or --quiet |
Completely quiet (never ring the terminal bell) |
-Q or --QUIET |
Completely quiet, overrides -q |
-r or --raw-control-chars |
Display "raw" control characters |
-R or --RAW-CONTROL-CHARS |
Same as -r, but try to keep screen appearance |
-s or --squeeze-blank-lines |
Squeeze multiple blank lines into one |
-S or --chop-long-lines |
Cut off long lines rather than wrapping |
-t tag or --tag=tag |
Find a tag |
-T tagsfile or --tag-file=tagsfile |
Use alternative tags file |
-u or --underline-special |
Use underlining for special characters |
-U or --UNDERLINE-SPECIAL |
Don't use underlining for special characters |
-w or --hilite-unread |
Highlight first unread line after a forward move |
-W or --HILITE-UNREAD |
Highlight first unread line after any move |
-x N or --tabs=N |
Set tab stops |
-X or --no-init |
Don't use termcap init/deinit strings |
-y N or --max-forw-scroll=N |
Set forward scroll limit |
-z N or --window=N |
Set scroll size (in lines) |
-Z or --no-scroll |
Disable scrolling and follow terminal |
-" charset or --quotes=charset |
Set quote characters |
-~ or --tilde |
Don't display tildes after end of file |
-# N or --shift=N |
Set horizontal scroll amount |
Examples
How to Use These Examples
The examples below show common ways to use the less
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
less file.txt