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
or
>>logs.txt echo log informationI 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
:: mike
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.
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!)
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
