I have solved it with
echo. <^pre^> what ever with spaces ^</pre^> >>filename.html
it will keep the spaces
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to write this line to text file
from a batch file.
echo >temp.txt
I won't work, I have tried echo ^
and echo ^&^#160;
Help
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
I have solved it with
echo. <^pre^> what ever with spaces ^</pre^> >>filename.html
it will keep the spaces
What are you trying to do?
The string is HTML for a non-breaking space (also written )
The command interpreter doesn't understand HTML.
The command interpreter recognizes the ampersand (&) as a "command separator" which simply means that it treats whatever follows the & as a command. Thus, if you type the following in a command prompt
echo
the command interpreter attempts to interpret #160; as a command -- and it can't. Similarly, the command interpreter recognizes the semicolon (;) as a blank space (I think).
C:\Users\LemP>echo > temp.txt
ECHO is on.
'#160' is not recognized as an internal or external command,
operable program or batch file.
The caret character (^) "escapes" the ampersand, allowing the command interpreter to treat it as just another character. Thus the following
C:\Users\LemP>echo ^ > temp.txt
results in the creation of a file named temp.txt that contains the 6 characters
So ... depending on what you want your batch file to accomplish, there may (or may not) be a way to achieve that goal.
The following pages may be of interest: