The use of output, error, output append, and error append redirection not only allows us to easily implement the contents of multiple commands with a single file, but also gives us a deeper understanding of Linux.
Program: Instruction + data
Read-in data: Input
Outputs data: Output
Open files have a Fd:file descriptor (file descriptor)
Linux provides three I/O devices to Programs
Standard input (STDIN)-0 accepts input from the keyboard by default
Standard output (STDOUT)-1 Default output to terminal window
Standard error (STDERR)-2 default output to terminal window
1. Create a file with output redirection
650) this.width=650; "style=" Float:none; "title=" output redirection. PNG "src=" Http://s3.51cto.com/wyfs02/M02/85/4B/wKioL1efODijaNabAABJfGwqlqI345.png-wh_500x0-wm_3-wmp_4-s_ 2903575957.png "alt=" Wkiol1efodijanabaabjfgwqlqi345.png-wh_50 "/>
2. The use of output redirection
650) this.width=650; "style=" Float:none; "title=" output redirection creates a file. PNG "src=" Http://s1.51cto.com/wyfs02/M01/85/4B/wKiom1efODmQ3oY-AAAuxG9HtzQ891.png-wh_500x0-wm_3-wmp_4-s_ 3448822636.png "alt=" Wkiom1efodmq3oy-aaauxg9htzq891.png-wh_50 "/>
3. Output Append redirect
650) this.width=650; "style=" Float:none; "title=" Output append redirect. PNG "src=" Http://s1.51cto.com/wyfs02/M01/85/4B/wKioL1efODng4v_rAAAg_WG0R38344.png-wh_500x0-wm_3-wmp_4-s_ 4054924527.png "alt=" Wkiol1efodng4v_raaag_wg0r38344.png-wh_50 "/>
4. Output Redirection of ERROR commands
650) this.width=650; "style=" Float:none; "title=" error command output redirection. PNG "src=" Http://s4.51cto.com/wyfs02/M00/85/4B/wKiom1efODrxWRqqAAAPGDOJyAI682.png-wh_500x0-wm_3-wmp_4-s_ 3533114368.png "alt=" Wkiom1efodrxwrqqaaapgdojyai682.png-wh_50 "/>
5. You can use 2> to display the content output redirection of the error command
650) this.width=650; "style=" Float:none; "title=" error command output redirected display. PNG "src=" Http://s4.51cto.com/wyfs02/M02/85/4B/wKiom1efODrBa1upAAAOmCi7zwo420.png-wh_500x0-wm_3-wmp_4-s_ 509950746.png "alt=" Wkiom1efodrba1upaaaomci7zwo420.png-wh_50 "/>
6. Error command output append redirect
650) this.width=650; "style=" Float:none; "title=" error command output redirect append. PNG "src=" Http://s4.51cto.com/wyfs02/M02/85/4B/wKioL1efODvAxNajAAAjkkNS0iY176.png-wh_500x0-wm_3-wmp_4-s_ 3524765053.png "alt=" Wkiol1efodvaxnajaaajkkns0iy176.png-wh_50 "/>
7. Displaying incorrect and correct output redirects with the same file
650) this.width=650; "style=" Float:none; "title=" displays the wrong and correct one file at the same time. PNG "src=" Http://s4.51cto.com/wyfs02/M00/85/4B/wKioL1efODyySR8yAABBNR4od3U447.png-wh_500x0-wm_3-wmp_4-s_ 621888053.png "alt=" Wkiol1efodyysr8yaabbnr4od3u447.png-wh_50 "/>
8. You can also use 2>&1 to output incorrect and correct output redirects at the same time
650) this.width=650; "style=" Float:none; "title=" displays both the wrong and the correct 1 with a file. PNG "src=" Http://s3.51cto.com/wyfs02/M00/85/4B/wKiom1efODygS3fOAAAoy1ueuxI263.png-wh_500x0-wm_3-wmp_4-s_ 1703660663.png "alt=" Wkiom1efodygs3foaaaoy1ueuxi263.png-wh_50 "/>
9. Use different files to show the wrong and correct
650) this.width=650, "style=" Float:none, "title=" respectively with different files to display the wrong and correct. PNG "src=" Http://s1.51cto.com/wyfs02/M01/85/4B/wKiom1efOD3wcwTRAABD4zrjvzs553.png-wh_500x0-wm_3-wmp_4-s_ 2364845514.png "alt=" Wkiom1efod3wcwtraabd4zrjvzs553.png-wh_50 "/>
10. Use Set-c to enable output redirection without overwriting the contents of the original file
650) this.width=650; "title=" Set-c.png "src=" http://s5.51cto.com/wyfs02/M00/85/4B/ Wkiom1efoiusrrjiaaaofzqg63g711.png-wh_500x0-wm_3-wmp_4-s_2419286490.png "alt=" Wkiom1efoiusrrjiaaaofzqg63g711.png-wh_50 "/>
11. Using >| Force overwrite
650) this.width=650; "title=" enforces overrides. PNG "src=" Http://s4.51cto.com/wyfs02/M00/85/4B/wKioL1efOg_yNVPAAAAPZ1dE06U368.png-wh_500x0-wm_3-wmp_4-s_ 2115539089.png "alt=" Wkiol1efog_ynvpaaaapz1de06u368.png-wh_50 "/>
12. Unlock the Set +c
650) this.width=650; "style=" Float:none; "title=" Set +c.png "src=" http://s1.51cto.com/wyfs02/M02/85/4B/ Wkiom1efod7zyfddaaaimnztgx0928.png-wh_500x0-wm_3-wmp_4-s_248395984.png "alt=" Wkiom1efod7zyfddaaaimnztgx0928.png-wh_50 "/>
Over 13 commands simultaneous output redirection
650) this.width=650; "style=" Float:none; "title=" multiple commands output redirection at the same time. PNG "src=" Http://s2.51cto.com/wyfs02/M02/85/4B/wKioL1efOD_wttbcAABMcz5qLw8932.png-wh_500x0-wm_3-wmp_4-s_ 1934247432.png "alt=" Wkiol1efod_wttbcaabmcz5qlw8932.png-wh_50 "/>
Output, error, output append, error append redirect use