Redirection in bash
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 |
---|---|
|
This is a general-purpose command that chains similar to > |
|
This redirects the output of a command to a file |
|
This reads a file and passes it to the command |
|
This appends the output of the command to a file |
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.