This should be a simple one and I am dissapointed with myself but cant for the life of me find a solution! I am trying to write the number 1 to a text file in a BAT script. If I do the below it works but leaves a trailing space after the number which I cannot have. I know you can remove the trailing space by deleting the space between the 1 and the > (this works with letters) but with numbers all of a sudden I get a message saying – ECHO is OFF.
ECHO 1 > mytextfile.txt
*This works but leaves a trailing space*
ECHO 1> mytextfile.txt
*This gives me an error saying ECHO is OFF*
The problem is that
echo 1> myTextFile.txtwill not echo1, instead the echo command is empty and the redirection goes to stream 1.You could simply move the redirection to the front.