less — Page through a file with backward navigation and search across all 5 shells
Equivalents in every shell
less file.txtExternal pager, strict superset of `more`. `SPACE` / `b` page forward / back; `/pattern` searches forward, `?pattern` searches back; `n` / `N` next / previous match; `g` / `G` jump to start / end; `q` quits. `LESS=-R less` preserves ANSI colour. `less -F` auto-quits if the file fits on one screen.
less file.txtSame external. Zsh users typically set `export PAGER=less` and `export LESS="-R -i -F -X"`. `${PAGER:-less}` is the canonical pipeline target — `man` and `git` both honour it. Zsh widget `Esc-h` (run-help) pages help text through `$PAGER`.
less file.txtSame external. Fish auto-uses `less` for `--help` output of every builtin and function. `set -x LESS -R` in `config.fish` preserves colour escapes through `man` and `git diff`. Fish does not bundle its own pager.
less file.txtNO native `less` on Windows — install via `scoop install less` or `choco install less`. PowerShell `Out-Host -Paging` is the built-in fallback but lacks backward scrolling and regex search. PS 7 on Linux / macOS shells out to the system `/usr/bin/less` if invoked directly.
less file.txtNo native `less`. Install via scoop / choco / WSL, or use `more` (limited — see /cmd/more). Git for Windows bundles a `less.exe` at `C:\Program Files\Git\usr\bin\less.exe` — add to PATH to make it the default pager for cmd-side tools.
Worked examples
Open a file in the pager
less app.logless app.logless app.logless app.log # requires installed less, e.g. scoop install lessTail a file and keep paging as it grows
less +F app.logless +F app.logless +F app.logGet-Content app.log -Wait -Tail 0Preserve ANSI colour escapes in piped output
git diff | less -Rgit diff | less -Rgit diff | less -Rgit diff | less -R # less.exe requiredGotchas
- By default `less` STRIPS ANSI escapes — colourful output (git, ripgrep, diff) appears as raw `\e[31m...` codes. Pass `-R` (or set `LESS=-R` globally) to interpret them. `-r` also works but breaks line counting for very long files; prefer `-R`.
- Without `-F` (`--quit-if-one-screen`), `less` ALWAYS clears the terminal even if the input fits on the visible screen — a common annoyance when paging short output. Set `LESS="-F -X"` in your shell rc: `-X` skips the terminal-init / reset escapes so short content stays visible after `q`.
- In `+F` follow mode (`less +F app.log`, similar to `tail -f`), pressing `Ctrl-C` exits FOLLOW mode but leaves you IN the pager at the position the file had grown to. Press `q` to fully quit, or `F` to resume following. New users routinely think `Ctrl-C` exited but it did not.
- Searching with `/pattern` is REGEX by default — `(`, `)`, `?`, `+` are special. For literal-string search, prefix with `\`: `/\(notice\)`. The `-i` flag makes search case-insensitive UNLESS the pattern contains uppercase (smart case, like vim and ripgrep).
- Windows has NO `less` out of the box. Git for Windows bundles one in `C:\Program Files\Git\usr\bin\less.exe` (often THIS is what gets picked up when `git` invokes a pager), but standalone cmd / PowerShell sessions will not find it unless you add the path. PowerShell users on Windows commonly forget this and curse `more` for hours.