less
Files and directories
Usage
less [file]Pages through a file without loading all of it; / searches and q quits, and unlike more it never closes by itself at the end.
Common flags
| Flag | Meaning |
|---|---|
| -N | Show line numbers |
| -S | Chop long lines instead of wrapping them |
| -i | Ignore case while searching unless the pattern has capitals |
| -R | Pass color escape codes through as colors |
| +F | Start in follow mode, like tail -f |
| -X | Leave the output on screen after quitting |
| /word | Search forward; n repeats it, q quits less |
Examples
less +F /var/log/syslogFollows the log; Ctrl-C stops following and lets you scroll.
less -S wide.csvKeeps each record on one row so columns stay aligned.
git log | less -RPages colored output with the colors kept.
Moving, deleting and finding. Some of these do not ask twice, which is why -i becomes a habit.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does less do?
Pages through a file without loading all of it; / searches and q quits, and unlike more it never closes by itself at the end.
Q. How do I type it?
less [file] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
7 are listed here; the full set is in man less. This command sits under Files and directories.
Related commands
man page: man less