Interleave files with CMD using echo

前端 未结 1 497
滥情空心
滥情空心 2021-01-27 06:35

How could I interleave files line by line with

cmd.exe

with help of read, grep, echo, etc?

File1.txt with the context:

相关标签:
1条回答
  • 2021-01-27 07:17

    You need a method to read from two files in parallel. This is possible by using two methods at the same time (<file1 set /p and for /f ... in (file2)):

    @echo off
    setlocal enabledelayedexpansion
    
    <file2.txt (
      for /f "delims=" %%a in (file1.txt) do (
        set /p b=
        echo %%a
        echo !b!
      )
    ) >outcome.txt
    
    0 讨论(0)
提交回复
热议问题