About those script commands “1>” “2>” “2>&1”
-
Prepared file descriptior info
standard input file descriptor == 0
standard output file descriptor == 1
standard error file descriptor == 2 -
Prepared redirection operation info
> aims to redirect the output path elsewhere instead of standard location(such as previous 1, 2); note: it would overwrite the previous output results.
>> aims to redirect the output path elsewhere instead of standard location(such as previous 1, 2); note: it would append new results to the previous output.) -
Some examples to keep those points in mind.
1>loglist.txt : which represents that the succeed executive results would be stored to loglist.txt file.echo "hello_World!" >loglist.txt(or echo "hello" 1>loglist.txt)
2>errorInfo.log : which means the error msg of falilure to execute script cmd would be stored to errorInfo.log file.
call :hello_World >test.log 2>errorInfo.log
(respectively warning or error info stored to errorInfo.log file if callback failed, and normal msg to test.log if successed)
2>&1 :which represents that the error output of falilure to execute script cmd would be redirected to 1(stdout). //将标准错误输出重定向到标准输出
where git.exe 1>test.log 2>&1 ...
(//error info would be overwritten into test.log file if no git tool been installed in the PC)
Extension
1> nul : which represents that successful executive results would not be output(definitely the default output), however the failure to execute would be output by 2(standard error file descriptor)
2>nul : which represents that failed executive results would not be output, however the successful executive would be output by 1(standard output file descriptor)
ok, those words just marking what I’ve got in store for future application.In the future, maybe somewhere I really need those prep points.