How to break inner loop in nested loop batch script

前端 未结 3 1707
广开言路
广开言路 2020-12-15 06:38

MY goal is to compare two files line by line and capture the changes. For that i am using two nested loops. I am stuck with braking the inner loop on some condition.

<
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 07:30

    Even if the goto label is in the for loop, it also goes out the loop context. Such as

    @echo off
    for %%d in (A B) do (
        echo %%d
        for %%f in ( 1 2 ) do (
            goto loop
            :loop
            echo %%d %%f
        )
    )
    

    This will print out A %d %f

提交回复
热议问题