16.7 Using Redirection 237
Figure 16.11: cat demonstrates standard input and standard output
16.7 Using Redirection
Now that we have a handle on what standard input and standard output are, it’stimetoexpanda
little.
Redirection means causing the shell to change what it considers standard input or where the standard
output is going.
We used cat before to demonstrate the idea behind standard input and standard output. Now, let’s
use cat to see how standard output can be redirected.
To redirect standard output, we’ll use the > symbol. Placing > after the cat command (or after any
utility or application that writes to standard output) will direct its output to the filename following
the symbol.
Let’stryit.Inanxtermwindowtype:
[billy@localhost billy]$ cat > sneakers.txt
buy some sneakers
then go to the coffee shop
then buy some coffee
Now press
Enter to go to an empty line, and use the Ctrl and D keys to quit cat.
Comments to this Manuals