Полезная информация

Next Up Previous Contents Index
Using <tt>cat</tt>

2.6 Using cat

There's a handy utility which can help you keep short lists, gather those lists together and, at the same time, show you a little of the power behind your Red Hat Linux system.

The utility is called cat, short for ``concatenate,'' which means that it strings files together.

But cat can also perform a quick demonstration of two important terms: standard input and standard output.

Standard input and standard output direct input and output (often referred to as I/O) to the user. If a program reads from standard input, it will, by default be reading from the keyboard. If a program writes to standard output, by default it will be writing to the screen.

Let's start cat to see what this means. At the shell prompt, type:


The cursor moves to a blank line. Now, in that blank line, let's type:

stop at sneaker store

and press the [Enter] key. Suddenly, your screen looks like:

[billy@localhost billy] cat
stop by sneaker store
stop by sneaker store

Figure 30: cat demonstrates standard input and standard output

To quit cat now, just move the cursor to a blank line by pressing [Enter] then press the [Ctrl] and [D] keys at the same time.

So it's not too exciting. But cat has just demonstrated the definition of standard input and standard output. Your input was read from the keyboard (standard input), and that input was then directed to your terminal (standard output).

  • Summary: Standard input is often text which is entered from the keyboard. Standard output is the place where information is sent, such as your terminal (as shown in Figure 30).

  • Next Up Previous Contents Index