(1), standard input is code 0
(2), standard output is code 1
(3), standard error is code 2
REDIRECT Standard output
> writes the command output to a file or device.
< read command input from a file instead of from the keyboard or handle
>> add command output to the end of a file without deleting information already in the file
Cat passwd | Awk-f: ' {print $} ' | Sort >sort.out
REDIRECT Standard input
Cat >> Alvin.log <<eof
> My name is Alvin
> My name is Gongda
> Good bye,..
> EOF
[Email protected] ~]# ftp-i-N 127.0.0.1<<eof
> User FTP FTP
> dir
> EOF
Drwxr-xr-x 2 0 0 4096 Oct 23:54 Pub
REDIRECT Standard error
[[email protected] ~]# grep "Gongda" 111.txt
Grep:111.txt: No file or directory
Normally, an error is generated. This method standard 2 error redirection
# grep "Gongda" 111.txt 2>/dev/null
Standard output combined with standard error
# grep "root"/etc/passwd > 1.log 2>&1
2 >& 1 means that the error output is redirected to the handle 1 standard output; Combined, the standard output and error output generated during grep command execution are redirected to 1.log.
Standard input, standard output, standard error