I have a batch script that performs a task and sends out the output to a text file. Is there a way to show output to the console window?
For example:
c: \ Windows> gt; Dir> Windows-dir.txt
Is there a way to insert the dir
display in the console window as well as insert it into a text file?
I try to explain the redirection a bit.
You can use one of the ten streams > File or & lt; File
It is unimportant, if the redirection is before or after the order, then these two rows are almost identical.
dir> File.txt & gt; File.txt dir
Redirection in this example is only a shortcut for 1> , which means that stream 1 (STDOUT) will be redirected.
You can forward any stream with numbers such as 2> err.txt and there is also permission to redirect multiple streams in one line.
dir 1> Files.txt 2 & gt; Err.txt 3 & gt; Nothing.txt
In this example, "standard output" will go to files.txt, all the errors will be in err.txt and stream 3 will not get anything. Txt (DIR does not use section 3.) Stream0 STDIN
Stream1 is STDOUT
Stream2 is STDERR
Stream 3-9 is not used
But what happens if you try to redirect the same stream multiple times?
dir> Files.txt> Two.Txt
"can only be one", and it is always the last !! So this is equivalent to dir> two.txt
OK, there is an additional possibility, redirecting one stream to another stream.
dir 1> Files.txt2 & gt; & Amp; 1
2> and 1 stream 1 and stream 2 and 1> files.txt to all files.txt < / Strong>.
Order is important here!
DIRE ... 1 & gt; Nool 2 & gt; And 1 di ... 2 & gt; And 1 1> Null
is different, first one redirects all NUL (STDOTT and STDERR), but the second line redirects NUL and STDERR to "empty" STDOT by STDOT.
As a conclusion, it is clear why examples of Otavio Desio and Endinormax can not work.
command & gt; File & gt; And 1 Dior & gt; Both try to redirect to Stream 1 twice, but "can only be one", and it is always preceded.
Then you must press Command1> 1 and 1 Dior 1 & gt; & Amp; 2
and the 1st sample redirecting to Stream 1 in Section 1 is not allowed (and not very useful).
Hope this helps Pocket
Comments
Post a Comment