Findstr to read user-defined line from a "for" loop
Posted: 15 Jan 2012 01:29
SCENARIO:
(in test.txt)
(in my current batch file)
THE ISSUE:
After extensive trial and error I have concluded that findstr does not read only the first line, it "picks out" the string from the file test.txt rather than reading line by line.
I need it to read the file on a line that I set (as a variable).
Thanks in advance.
Regards,
Rileyh
(in test.txt)
Code: Select all
(empty line)
printline Hello World
(empty line)
(in my current batch file)
Code: Select all
@echo off
setlocal enabledelayedexpansion
:loop
set "$file=test.txt"
for /f "tokens=1-2*" %%a in ('findstr /b /i "printline" "!$file!"') do (
set command=%%a
set value=%%b
echo %%b
goto :break
)
:break
(file continues)
THE ISSUE:
After extensive trial and error I have concluded that findstr does not read only the first line, it "picks out" the string from the file test.txt rather than reading line by line.
I need it to read the file on a line that I set (as a variable).
Thanks in advance.
Regards,
Rileyh