2

I use to press CTRL+C, but there are some cases where this key combination doesn't work. E.g. if you open the perl docs:

perldoc File::Path

The documentation is presented on the terminal and I can't get out of it. I must close the terminal and it's a little frustrating.

2 Answers 2

4

It really depends on the application that is used to open a document. perldoc uses application defined in PERLDOC_PAGER, MANPAGER, or PAGER environment variable.

It defaults to less viewer on most systems, so you should press q when browsing the document. But if by accident you pressed other keys, you might need to finish the operation before q would allow you to quit.

Wikipedia article on less has its keyboard shortcuts explained in detail.

1

The conventional meaning of Ctrl+C is “stop this command and go back to a command prompt”. For simple programs, that means killing the program and going back to the shell prompt. But for interactive programs that have their own command loop, that means stopping what the program is doing right now (e.g. a search) and going to that program's command loop.

The generic name for a program that allows browsing through a text file in a terminal is a pager. The default pager on virtually all installations except some ancient or embedded systems is less. In less, press q to quit, and h to see help. (? does a backward search, not help, because / is the traditional key for search and ? is Shift+/ on US keyboards.)

Beyond Ctrl+C, another terminal key combination that's good to know is Ctrl+Z. Its default action is to suspend the current program and bring you back to a shell prompt. You can then use the shell command fg to bring the program back to the foreground, jobs to list the suspended programs, and kill %1 to kill the suspended program that jobs lists as [1] ….

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.