CMD or Powershell command to combine (merge) corresponding lines from two files

前端 未结 6 1677
说谎
说谎 2020-11-29 12:56

Is it possible using CMD and Powershell to combine 2 files into 1 file like this:

file1-line1 tab file2-line1
file1-line2 tab file2-line2
file1-line3 tab file2-li         


        
6条回答
  •  死守一世寂寞
    2020-11-29 13:31

    Powershell solution:

    $file1 = Get-Content file1
    $file2 = Get-Content file2
    $outfile = "file3.txt"
    
    for($i = 0; $i -lt $file1.length; $i++) {
      "$($file1[$i])`t$($file2[$i])" | out-file $outfile -Append 
    }
    

提交回复
热议问题