User Tools

Site Tools


ops102:brainteaser_more

Brainteaser: More

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.

ops102/brainteaser_more.txt · Last modified: 2024/06/13 23:41 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki