Installation guide
110 Chapter 11. Shell Prompt Basics
Figure 11-6. Joining Files and Redirecting Output
You can see that cat has added home.txt where sneakers.txt ended.
11.9.2. Appending Standard Output
You can use output redirection to add new information to the end of an existing file. Similar to when
you used the
symbol, you tell your shell to send the information somewhere other than standard
output.
However, when you use
, you are adding information, rather than replacing it.
The best explanation is a demonstration. Take two files which have already been created
(sneakers.txt and home.txt) and join them by using the append output symbol. You want to add
the information in home.txt to the information already in sneakers.txt, so type:
cat home.txt sneakers.txt
Now check the file using the command cat sneakers.txt. The final output shows the contents of
home.txt at the end of the file.
[sam@halloween sam]$cat sneakers.txt
buy some sneakers
then go to the coffee shop
then buy some coffee
bring the coffee home
take off shoes
put on sneakers
make some coffee
relax!
[sam@halloween sam]$
The command you typed told the system to append the output from the file home.txt to the file
sneakers.txt.
By appending the output, you save yourself time (and a bit of disk clutter) by using existing files,
rather than creating a new file.
Compare the results of the files sneakers.txt and saturday.txt now, and you will see that they
are identical. To make your comparison, type:
cat sneakers.txt; cat saturday.txt
The contents of both files will be displayed — first sneakers.txt, then saturday.txt (as shown
in Figure 11-7).