Search code examples
batch-filelinecounterincrement

Is it possible to read the next line of a file only if a particular IF statement is valid?


I wondered, is it possible to skip reading a line in a FOR /F loop if a certain IF statement is valid in it? For example:

FOR /F "tokens=* delims=" %%j in (exclusions.txt) do ( 
IF %SomethingIDeclaredBefore%==%%j (jump to the next line of the text file) else (echo not equal)

I suppose it's impossible to increment %%j.


Solution

  • How about

    for /l %%C in (1,1,254) do (
     findstr /b /e "172.24.104.%%C" exclusions.txt >nul
     if errorlevel 1 (echo shutdown) else (echo skip)
    )