
16.9 Redirecting Standard Input 241
Now let’scheckthefile by typing:
cat sneakers.txt
And there it is – with the contents of home.txt at the end.
What we were saying when we typed that command was, “append the output from the file home.txt
to the file sneakers.txt.”
By appending the output, we’ve saved ourselves a step or two (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 now, and you’ll see that they’re
identical. To make your comparison, just type:
cat sneakers.txt; cat saturday
The contents of both files will be displayed - first sneakers.txt,thensaturday (as shown in
Figure 16.14).
Tip: Remember that when you append output, you’ve got to include the double greater-
than symbols (>>). Otherwise, you’ll end up replacing the very file to which you want
to append information!
(By the way, if you’re curious about the use of the semi-colon in that last command, read on. We’ll
cover that later in this chapter.)
Summary: To append output, use two greater-than symbols (>>). For example: cat
addthisfile >> tothisfile.
16.9 Redirecting Standard Input
Not only can you redirect standard output, you can perform the same type of redirection with stan-
dard input.
Here’showitworks:
When you use the redirect standard input symbol <,you’re telling the shell that you want a file to be
read as input for a command.
We can use a file we’ve already created to demonstrate this idea. Just type:
Kommentare zu diesen Handbüchern