In the Linux operating system, we will have some of these requirements, for example, we need to use the shell to write some automated operations scripts, and need to save the execution of the script to another text, this is called output redirection. Sometimes we send an e-mail message that reads from a specified file requires the use of input redirection.
Standard input (stdin) 0
Standard output (STDOUT) 1
Standard error Output (STDERR) 2
Input redirect
Cat </etc/passwd
Output redirection (overwrites the original content)
Df-h >/tmp/disk
Append output redirection (does not overwrite the original content)
Df-h >> Disk
Error output redirection
CAT/ETC/PASSWD 2> A
CAT/ETC/PASSWD 2>/dev/null
Dual output
Cat/etc/abc > OK 2> NG
Input/Output merge (&)
CAT/ETC/PASSWD &>> All
Special Equipment files
/dev/zero Unlimited 0 Resource equipment
/dev/null Trash Cans
Input Terminator
Cat > B << ok normal exit after encountering OK
Cat > B--->ctrl + d normal end
--->ctrl + c forced end
Piping mechanism (TEE)
The pipeline can give the result of a script or command execution to the process behind the pipeline to continue processing
cat/etc/passwd | Wc-l
41
cat/etc/passwd | grep FTP
Ftp:x:14:50:ftp User:/var/ftp:/sbin/nologin
cat/etc/passwd | Wc-l | TEE-A ABC
Tee saves the results of full execution to abc-a append
This article is from the Cloud computing blog, so be sure to keep this source http://huanghaisky.blog.51cto.com/3064496/1918927
Linux Input/Output redirection