Here's an interesting thing to think through:
Normally, the standard input (stdin) of a program is used for input from the terminal. For example, the nano
editor uses stdin to get keystrokes from the user.
The output of any command or program that produces a lot of text can be piped into the more
program so that is displayed one screen at a time to the user. For example, you can take the output of the ls
command and direct it into more
like this:
ls | more
When used in this way, the stdin of the more
command is connected to the ls
command. Therefore, it can't be used to get keystrokes from the user.
How does more
read the keyboard to determine when the user presses a key to see the next screen?
(The same concept applies to both the Windows and Linux version of more
, as well as to the Linux less
command).
Try to determine the solution, then click here to check your answer.