|
|
You have already seen one example of how to put the output of a command into a file: cat > file
Here, cat opens a file and waits for you to type into it. The file is closed when you press <Ctrl>D, the end-of-file (EOF) character. The greater-than sign is the redirection symbol; it tells the computer you want the output of cat to go into a file instead of the usual place. This is called ``redirecting standard output,'' or simply ``redirection.''
You can use redirection with any command that prints information on the screen. For example, you could redirect the output of ls into a file and then print this file to get a printed directory listing.
Try printing a long listing of the files in your home directory:
The usual place a command gets its input from is known as standard input. Standard input is usually your keyboard. You will learn how to use a file as standard input later in this chapter.
Standard output and standard input are sometimes referred to as ``standard out'' and ``standard in,'' or ``stdout'' and ``stdin.''