One of the more advanced features of bash are the redirection operators. These operators allow you to divert the input or output of a command to another command or file. While this sounds simple, it is an extremely powerful feature. There are several redirection operators built into bash, as shown here:
Operator |
Description |
---|---|
| |
| |
| |
|
Redirection operators
The |
operator is a general-purpose command-changing tool. A simple example of this is to use it with cat
and the program more
. The more
program is a simple program that lets you move backward and forward throughout a file on the screen in order to read it. The more
command gets the data that you want to read from the cat
command. The |
operator connects two programs together.
The >
and >>
operators are really powerful operators that take the data that is output by a program and write it to a file. The >
operator replaces the file and the >>
operator appends it to a file.
Remember that everything in Linux is a file, so you can use the >
and >>
operators to direct the output to a serial port or a printer.