Program: Instruction + Data
Data entry: Interactive, file, process
Data output: Monitors, files, processes
Standard input (stdin): 0, keyboard
Standard Output (stdout): 1, monitor
Error Output (stderr): 2, monitor
The normal output and error output are two different data streams;
Redirect:
Output redirection: , >>
COMMAND> new_position: overwrite redirect, will empty the file data ;
CAUTION: hazardous operation; To turn off this feature, you can use the set-c " , the opposite action is "set+c"
COMMAND>> new_position: Follow-up orientation , new data will be appended to the original file data;
Error Output redirection: 2>, 2>>
Command2> Err_output Overwrite the contents of the file
command2>> err_output appended to file data
Two output data streams are also directed :
Method One:
COMMAND> out_file 2>&1
COMMAND>> out_file 2>&1
Method Two:
COMMAND&> out_file
COMMAND&>> out_file
Enter redirection:
command< new_in
TR Command :
Tr[option] ... SET1 [SET2]
put the output data in the each character in the SET1 is correspondingly replaced by each character of the SET2;
-D: Deletes the data that appears in the input stream that belong to each corresponding character of the SET1;
COMMAND << EOF [EOF represents end of File]
[[email protected] tmp]# cat << EOF >abc.txt> I am lx> Hello world> eof> eof[[email protected] tmp]# Cat abc.txt I am lxhello worldeof
REDIRECT content output from input redirection to in the Abc.txt file, EOF can be substituted with any string, case-sensitive
Pipeline: |
put The output of COMMAND1 as the input of COMMAND2, and then the output of COMMAND2 as the input of COMMAND3, etc. .
command1| COMMAND2 | COMMAND3 | ...
Multi-Channel output:
command| Tee/path/to/somefile
Tee Command : The standard input is displayed in the standard output and saved to the file xx, if xx file does not exist is created, the existence will overwrite;
[-A]: append to the back of the file , rather than covering
This article is from the "xxlixin" blog, make sure to keep this source http://xxlixin1993.blog.51cto.com/9498220/1625961
I/O redirection