我需要一些帮助。我想用if-else语句执行for循环,但是我遇到了一些错误。 这是我的代码
mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" | FOR /F %%D IN ('C:\Windows\System32\findstr /V "information_schema performance_schema"') DO (IF EXIST %pathx%\%%D (echo test) ELSE (echo fail))
输出
< was unexpected at this time
答案 0 :(得分:1)
您的错误报告不正确。您收到的输出是
( was unexpected at this time
您无法将输出有效地输出到for
语句中。将您的代码更改为
FOR /F %%D IN ('mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" ^| C:\Windows\System32\findstr /V "information_schema performance_schema"') DO (IF EXIST %pathx%\%%D (echo test) ELSE (echo fail))