Less -K or –quit-on-intr option causes less to exit immediately (with status 2) when an interrupt character (usually ^C) is typed. Normally, an interrupt character causes less to stop whatever it is doing and return to its command prompt. Note that use of this option makes it impossible to return to the command prompt from the “F” command.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
## create a long file with 200 lines > myfile; i=1; while [ $i -le 200 ]; \ do echo "$i" >> myfile; ((i++)); done ## default less myfile ## press control + c ## returns the prompt with bell alert ## less -K or --quit-on-intr options less -K myfile ## press control + c ## exit less with bell alert rm myfile |