Solved Looking for a better resource on redirection in batch

November 15, 2012 at 07:36:37
Specs: Windows XP, 2.793 GHz / 1014 MB
I have been trying to wrap my head around some of the way redirection works in batch files. I know that you can use the following

echo log information>>logs.txt
>>logs.txt echo log information

I just don't quite understand all the options on the second piece, and was hoping there was something that explains a little more about it. I know this is fairly basic stuff, I just have always done things the first way. Thanks in advance.


:: mike

See More: Looking for a better resource on redirection in batch

Report •

November 15, 2012 at 08:48:37
✔ Best Answer
With the file redirection operators, it's always
<redirection operator> <file path>
Don't let its position relative to the rest of the command throw you.

How To Ask Questions The Smart Way

Report •

November 15, 2012 at 10:49:22
From my understanding, the main reason format no. 2 is used is to keep the space from coming into the stream when people type:
echo no spaces! >> test
thinking they need to separate the text and the redirects with a space, which is wrong. Your version of format no. one is correct to not have the space. The only problem with format two is it could have a trailing space or spaces off the end of the text and you don't see it readily.Sometimes i use () for that reason:
>>test (echo no spaces!)

Report •

November 17, 2012 at 12:58:08
I just have been seeing it more and more, and my brain is stuck in basic mode(since that's what I have worked with). Thanks for both the responses.

:: mike

Report •
Related Solutions

Ask Question