Linux Learning Fifth session
--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------
31. Standard input and output
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
I/O redirection: Changing the default location
32. Operation Symbol
> redirect the stdout to a file and output the correct results to a file;
2> redirect the stderr to the file, the wrong prompt output to the file;
&> Redirect all outputs to a file and output all the results to a file;
>> additional content;
2> Overwrite redirect error output data stream;
2>>-weighted directional error output data stream;
&> overlay redirection;
&>> pursuit of heavier orientation;
Command > File 2>&1 (Order is important);
Command >>/path/to/file.out 2>&1;
(): Merging the stdout of multiple programs (command 1; command 2) > all.txt;
< REDIRECT standard input, can be understood as influence, tr ' A-Z ' A-Z ' </ETC/ISSUE,TR command results in effects to/etc/issue, so that all lowercase letters under the file become uppercase;
Cat > File input After enter will appear the cursor flashing, enter the input file files have content;
Cat > Filea < Fileb after input Fileb file contents will appear in Filea;
<< termination words, mail or script at the beginning of the text, the input after the end of the word is terminated, generally with EOF
33. Pipeline
Command 1| Command 2| command 3| .... Pass the correct result of command 1 to command 2, the correct result after processing to the command 3, and so on, this command only transmits the correct results, if you want to pass the error result also, you can use 2>&1 or |&
Linux Learning Fifth Lesson-standard I/O and piping