1. I/O redirection: Modify the default input and output devices
stdout/output Redirection, code 0: Change the sent data channel (STDOUT) to output to the specified file
: Saves the output to the specified file by overwriting, such as saving the results of the LS/command execution in the files file:
LS/> file
>>: Saves the input as an append in the specified file, for example in the original file to have some content, but instead writes with >> append
stdin/input redirection, code 1: Change the read-in data channel (stdin), refers to read from the specified file
<: Reads data from the specified file
<<:here document, and also means to establish documentation here
stderr/standard error output, code 2: When we execute the command may cause the command to fail because of the command write error or other problem, when the output is wrong input, naturally cannot be redirected with standard output
2>: Saves the wrong information in the specified file in the Overwrite mode
2>>: Save the wrong information in the specified file in append mode
It is important to note that the correct input information and error output information are output, but not the same mechanism, because the execution status of the Linux command results in a 0-type representation of the correct execution, 1 for the error, and 2 for the error
Use &> or 2>&1 to save standard output and standard error output in the same file
/dev/null is a data black hole, we can export useless information, not want output information together to this directory
2, | Pipe: The result of the previous command as input to the next command
Cat Inittab | Wc-l
Using cat to view inittab content to the WC to count the total number of rows, the pipeline can use more than one, the result of the first command as the input of the second, the result of the second article as the input of the third, and so on
This article is from the "Pole Men" blog, please be sure to keep this source http://wtime.blog.51cto.com/8829658/1530604
Linux Learning Pipeline and IO redirection