How do I echo the number 2 into a file, from a batch script?
This doesn\'t work:
Echo 2>> file.txt
because 2&g
Or you can use the delayed expansion
setlocal EnableDelayedExpansion
set "var=2"
echo(!var!>> file.txt
Based on this answer, if anyone is wondering how to do this:
echo "command1 && command2" > file.txt
with no qoutes in file.txt
then you do it like this:
echo command1 ^&^& command2 > file.txt
Tested on Windows Server 2003.
Little-known feature: The redirection operator can go anywhere on the line.
>>file.txt echo 2
Use the ^
escape :
Echo ^2>> file.txt
another method
echo>>file.txt 2