Reputation: 31
I have looked all over and found basically the same info, I am using :
for /f "skip=1" %%p IN ("%tmp%") DO (set var1=%%p)
but I am either not getting the second line or its not reading anything, how ever if I do
for /f "usebackq skip=1 delims=" %%p IN ("%tmp%") DO (set var1=%%p)
I will get the last line of the tmp file
The tmp file has 3 lines, the first one is useless (its an out put from a sql script) , The second line is a count, what i want, And the last row is just (1 rows affected), which i also don't want
Upvotes: 1
Views: 44
Reputation: 38579
If you know you only want line two, then the simplest way is to forget about using a For
loop, and instead use Set
with standard input:
@<"InputFile.txt" (
Set/P"line2="
Set/P"line2=")
@Set line2&Pause
I added the last line, just for you to see the assigned variable value. You'll note also that I used a direct string for the input file, you can of course use a variable, but please try not to use one with the name of an existing windows variable.
Upvotes: 1