Next 14.D: Appending Files with << Up 14: File Utilities Prev 14.B: The cat command Contents


Specialized

§ 14.C: I/O Redirection


The symbol < stands for redirect standard input. It allows you to take input from a file instead of the (default) keyboard. For example, you can use it to run a program with input from a file.

The related symbol > stands for redirect standard output. It allows you to direct output to a file instead of the (default) video screen. For example, you can use it to run a program with output to a file.

You can use output redirection with the cat command to create a file:

Here the control-d (^d ) is used to end data entry. Whatever lines you enter, including carriage returns, will be placed in the file hello.

Another way to use cat and < to create a file, is to copy any number of files into the present one

Be careful not to use the same name for input and output files. If you do, cat creates the file first and will therefore erase your input file before writing the output file.

Now use the cat command to view the new file. (Quiz)

In the next section we will use the append symbol to input from and output to the same file.


Next 14.D: Append with << Up 14: File Utilities Prev 14.B: The cat command Contents