I create a simple batch to replace a specific string in a file and dump the output to a new file:
set oldstring=SERVER_IP
set newstring=10.10.10.1
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in (test.txt) do (
set str=%%i
set str=!str:%oldstring%=%newstring%!
echo !str!>>newfile
)
If I run it on a file containing caracter 'a' a line feed, then a white space and a line feed I get the wrong output.
a[lf]
[lf]
OUPUT:
a
SERVER_IP=10.10.10.1
Why do I get this the string I'm trying to replace in the output whenever I have a line full of white spaces?
EDIT
Expected output
a