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.txt
will not echo 1
, instead the echo command is empty and the redirection goes to stream 1.
You could simply move the redirection to the front.
>mytextfile.txt echo 1
1>
is a special command. Use (ECHO 1) > mytextfile.txt
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With