Installation guide
Chapter 11. Shell Prompt Basics 109
Figure 11-5. Redirecting Output to a File
Press [Enter] to go to an empty line and use the [Ctrl]-[D] keys to quit cat.
Notice the difference (see Figure 11-5)? There are no repeated entries. That is because the standard
output from cat was redirected. That redirection was to a brand new file you made called sneak-
ers.txt.
You can find the file in the directory you were in when you started cat (type ls if you want to see it
listed).
As you learned earlier, you can then use cat to read the file. At the prompt, type:
cat sneakers.txt
Caution
Be careful when you redirect the output to a file, because you can easily overwrite an existing file!
Make sure the name of the file you are creating does not match the name of a pre-existing file, unless
you want to replace it.
Use output redirection again for another file and call it home.txt. For this example, type the follow-
ing:
[sam@halloween sam]$cat
home.txt
bring the coffee home
take off shoes
put on sneakers
make some coffee
relax!
Now, on an empty line, use the [Ctrl]-[D] key combination again to quit cat.
Next, use cat to join home.txt with sneakers.txt and redirect the output of both files to a brand
new file called saturday.txt (you will find an example in Figure 11-6). Type the following:
[sam@halloween sam]$cat sneakers.txt home.txt
saturday.txt