作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在批处理文件中使用 for 循环交替打印 2 个单独的 txt 文件的每一行,我尝试使用 AND 但在我运行时在 cmd.exe 中给出:“AND was unexpected at this time”我的批处理。有什么想法吗?
FOR /F "tokens=*" %%F in (!logPath!) AND for /f "tokens=*" %%H in (%%refLogPath) DO (
REM print each line of log file and refLog file sequentially
echo %%F
echo %%H
REM set logLine=%%F
REM check 'each line' of log file against ENG-REF.log
)
最佳答案
没有像AND
这样的关键字,通常你不能用两个FOR循环来解决这个问题。
但是还有另一种方法可以使用 set/p
读取文件。
setlocal EnableDelayedExpansion
<file2.txt (
FOR /F "delims=" %%A in (file1.txt) DO (
set /p lineFromFile2=
echo file1=%%A, file2=!lineFromFile2!
)
)
关于batch-file - For循环批处理中的多个条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11230722/
我是一名优秀的程序员,十分优秀!