Standard input: 0 <, << or 0< 0<<
Standard output: 1 >,>> or 1>,1>>
Error Output: 2 2>>,2>
/dev/null 这个设备,是linux 中黑洞设备,什么信息只要输出给这个设备,都会给吃掉 Send standard output, error output to/dev/null
$
ls
test
.sh test1.sh >
/dev/null
2>&1&,&1 represents the standard output &2 represents the error output
The//Error output is written directly in the standard output, which is displayed on the terminal screen.
: ~$ Ls-yz 2>&1
Ls:invalid option--' Y '
Try ' ls--help ' for more information.
The error output is output to the standard output, which is displayed on the screen and not written in the fname file.
: ~$ Ls-yz 2>&1 1>fname
Ls:invalid option--' Y '
Try ' ls--help ' for more information.
: ~$ ls
Androidstudioprojects Desktop Documents Downloads examples.desktop fname Music Pictures public Templates USR Videos work
: ~$ Cat FName
The// standard output is written in the fname file, and the error output is output to the standard output, which is the file fname.
: ~$ Ls-yz 1>fname 2>&1
: ~$ ls
Androidstudioprojects Desktop Documents Downloads examples.desktop fname Music Pictures public Templates USR Videos work
: ~$ Cat FName
Ls:invalid option--' Y '
Try ' ls--help ' for more information.
Shell input and output redirection