less is a terminal pager program used to view (but not change) the contents of a text file one screen at a time.
Questions tagged [less]
413 questions
272
votes
3 answers
Open `less` scrolled to the end
Is there a way to open less and have it scroll to the end of the file? I'm always doing less app.log and then pressing G to go to the bottom.
I'm hoping there's something like less --end or less -exec 'G'.

Miles
- 6,927
121
votes
3 answers
How do I write all lines from less to a file?
I've piped a command to less, and now I want to save the command's output to a file. How do I do that?
In this case, I don't want to use tee, I want a solution directly from less, so that I don't have to rerun a long-running command if I forgot to…

Flimm
- 4,218
50
votes
2 answers
How does `less` take data from stdin while still be able to read commands from user?
As most of you have done many times, it's convenient to view long text using less:
some_command | less
Now its stdin is connected to a pipe (FIFO). How can it still read commands like up/down/quit?

iBug
- 3,508
48
votes
4 answers
less --quit-if-one-screen without --no-init
I'm on a terminal that supports the alternate screen which is used by less, vim, etc. to restore the previous display after exiting. That's a nice feature, but it really breaks the --quit-if-one-screen switch of less since in that case less switches…

ThiefMaster
- 2,337
35
votes
2 answers
How do you make less show the filename?
I often have multiple terminal windows opened with less (eg comparing various log files). I forget which file is which. Is there a similar command to ^G in vi which displays the name of the file currently being viewed?

grasevski
- 493
20
votes
2 answers
Force less to display a file as text
Sometimes less wrongly recognize file as binary and tries to show hexdump on LHS (usually ones with non-alphanumeric characters but still containing printable ASCII characters). How to force it to recognize it as text?

Maja Piechotka
- 16,676
16
votes
3 answers
Search in less with wrap-around at EOF
Is it possible to enable "wrap around" in less for the search? This means: If the last occurrence of a pattern has been found, pressing n will start the search again at the beginning of the file (so you do not have to press g and then n).

viuser
- 2,614
15
votes
2 answers
How can I disable `v` keybinding in less?
When I use less and press v it switches into the currently set editor (Emacs or vim).
MISCELLANEOUS COMMANDS
v Edit the current file with $VISUAL or $EDITOR.
Is it possible to prevent this behavior where I don't want current file to be open in…

alper
- 469
15
votes
2 answers
Constantly display status line in less
I know I can have less show me the status line with =. Is there a way to have it displayed constantly and updated as I scroll through the file? When I use man it's actually done this way but I don't know how it's configured.

musiKk
- 583
14
votes
2 answers
Where does less store history of search patterns?
Let's say I open a file with less and look for a pattern such as
/time=32, then exit with q, and maybe run other commands. Then, if
I open the same file again with less and hit n to repeat the last
pattern sought, less remembers it from the first…

jchanger
- 401
13
votes
1 answer
show colors and disable line wrap
Using the less paginator, you can use the -r option to properly display colored input and the -S option to disable line wrap.
However, when using less -rS or equivalently less -r -S, colors are diplayed but lines are wrapped. How can this be…

Davide
- 273
12
votes
1 answer
less command stuck in forward scrolling
When piping command output into less, I'll scroll to the bottom of the output using the mouse and I'll find less gets stuck in forward scrolling, preventing me from scrolling back through output. This is the same behaviour as pressing F. Is there a…

retrohacker
- 223
12
votes
1 answer
Getting around *extremely* long lines in less
When navigating log files with less (e.g., using Space and B), sometimes I run into extremely long lines, as in 120,000 characters long long. It gets slow to navigate around these, I guess because it has to figure out what can go in the terminal and…

Captain Man
- 1,186
12
votes
1 answer
Make "less" jump point to center of search result rather than top
If one searches in less by typing /search term and jumping to search results with n and N the view of the text jumps so that the occurrence of the search term is at top of the terminal. Displaying the half of text before and after the occurrence is…

Kalle Richter
- 2,192
11
votes
2 answers
How to set up hjkl for less?
less already uses j/k for vertical scrolling, but not h/l for horizontal scrolling (in --ch mode). The l key isn't bound to anything anyway, and h is just a synonym for H, so I wouldn't overwrite any important bindings.
How can I make h and l scroll…

Anna
- 1,139