Pipeline and redirection under Linux
System default settings:
Standard input: stdout,0
Standard output: stdin,1
Standard error Output: stderr,2
2.I/O Redirect:
: Overwrite output
SET-C: Disallow redirection of existing file overrides
To force overwrite output redirection: Use >|
Set +c: Enables redirection of file overrides that already exist
>>: Append output
2>: standard error output
2>>: Standard error Append method
&>: Standard or error output to the same file
Example Description: ls/etc/&>/tmp/err.txt
>filename 2>&1: As with the &> function, the output of standard or error to the same file
Example Description: ls/etc/>/tmp/err.txt 2>&1
<: Input redirection
<<eof:eof to the end, you can write the concluding character arbitrarily
To illustrate:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/E1/wKioL1cLr9yS_MgtAAC4PyEIlq8987.jpg "title=" Eof.jpg "alt=" Wkiol1clr9ys_mgtaac4pyeilq8987.jpg "/>
3. Pipeline: The output of the previous command, as input to the latter command
Format: Command 1 | Command 2 | Command 3 | ...
Tee: Copies a copy saved to the specified file, and then prints one copy of the output to the screen
3.1. Example: Remove the user name and UID from the/etc/passwd file, and display in descending order of the UID number;
cut-d:-f1,3,/etc/passwd | SORT-T:-k2-n-R
3.2. Example: Remove the user name and UID of the 6th user in the/etc/passwd file and the shell, display it to the screen and save it to the/tmp/pw.txt file
Cut-d:-f1,3,7/etc/passwd | Tee/tmp/pw.txt
3.3. Example: Append alias COPY=CP line to the current user's. bashrc file without using a text editor
echo "Alias COPY=CP" >> ~/.BASHRC
This article is from the "Xavier Willow" blog, please be sure to keep this source http://willow.blog.51cto.com/6574604/1762757
Pipeline and redirection under Linux