Less Command – How to Exit When Reading from Stdin with ‘less -‘

exitlessstdin

Is there a proper way to exit less - without having to kill the process?

I accidently created a file called - (minus) and tried to view it with:

less -

Less than follows stdin and I did not find any way to exit it properly. I had to ctrl-z and kill the process. Is there some sort of escape char or any other way to exit less - without killing it?

PS: I know the proper way of viewing a file called - is less ./-.

Best Answer

(Not sure why @Kusalananda didn't submit this as an answer.)

Hold Enter until the cursor reaches the bottom of the window. Then the expected : will appear, and pressing q will quit.

Related Question