Number
0 standard input (stdin)
1 standard output (stdout)
2 standard error (STDERR)
Data redirection:
When executing a command, some commands execute when the result of successful execution or the process at execution and the execution of the command fail to execute the error prompt output to the terminal
Standard output, standard error output message to Terminal (Terminal) by default
Data redirection is the data that is exported by default to the terminal and uploaded to other files or devices
Use the command > file stdout to redirect to a file
Redirect the date output to the file file if the file does not exist
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/76/4F/wKioL1ZO43HymgVmAACN1gM7cTI380.png "title=" Rhce7-classroom-2015-11-20-17-05-30.png "alt=" Wkiol1zo43hymgvmaacn1gm7cti380.png "/>
Overwrite the file if it exists
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/76/50/wKioL1ZO5dyD8h3rAAA71gaDgKU836.png "title=" Rhce7-classroom-2015-11-20-17-17-33.png "alt=" Wkiol1zo5dyd8h3raaa71gadgku836.png "/>
Use the command > > file to append to the current file without overwriting the original file
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/76/51/wKiom1ZO5xrgiKb0AABEPE9awCA885.png "title=" Rhce7-classroom-2015-11-20-17-23-59.png "alt=" Wkiom1zo5xrgikb0aabepe9awca885.png "/>
Note Redirection stdout can prevent the process output from appearing on the terminal but cannot prevent STDERR error message output on the terminal
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/76/52/wKiom1ZO6deifezjAABBOcJSpkI926.png "title=" Rhce7-classroom-2015-11-20-17-36-05.png "alt=" Wkiom1zo6deifezjaabbocjspki926.png "/>
Use the command 2> file stderr to redirect files
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/76/51/wKioL1ZO6tCDYkYJAABwBVg2P18729.png "title=" Rhce7-classroom-2015-11-20-17-36-32.png "alt=" Wkiol1zo6tcdykyjaabwbvg2p18729.png "/>
The command 2>> file indicates that the stderr is appended to the file
REDIRECT stdout stderr to/dev/null and discard it (just not shown)
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/76/51/wKioL1ZO696zdOL3AABFHYnm77Q766.png "title=" Rhce7-classroom-2015-11-20-17-43-58.png "alt=" Wkiol1zo696zdol3aabfhynm77q766.png "/>
REDIRECT StdOut stderr to the same file at the same time
Command &> file
[[email protected] ~]$ find/etc-name passwd &> file
2. Command > file 2>&1
[Email protected] ~]$ find/etc-name passwd > File 2>&1
Be careful not to think the same. Redirecting to the same file at the same time may cause confusion in the data cross-write order
[Email protected] ~]$ find/etc-name passwd > file 2> file
Append stdout stderr to the same file at the same time
Command > > file 2>&1
[Email protected] ~]$ find/etc-name passwd >> file 2>&1
This article is from the Linux Learning Notes blog, so be sure to keep this source http://10516823.blog.51cto.com/10506823/1715205
Linux Data redirection