简体   繁体   English

如何在Windows 7命令提示符中水平合并文件?

[英]How to merge files horizontally in Windows 7 command prompt?

I have three files in a directory 我的目录中有三个文件
File 1: 文件1:

a b
c d

File 2: 档案2:

1 2
3 4

File 3: 文件3:

e f
g h

I know that in windows command prompt, when I type "copy * new.txt", I get a file called new.txt which looks like the following. 我知道在Windows命令提示符下,当我键入“ copy * new.txt”时,我得到一个名为new.txt的文件,如下所示。

a b
c d
1 2
3 4
e f
g h

In command prompt, how would I combine the files horizontally, so I get the following for my combined file? 在命令提示符下,我将如何水平合并这些文件,以便对合并后的文件进行以下操作?

a b 1 2 e f
c d 3 4 g h

You can install some proper (Unix/Linux) tools from here and do it like this: 您可以从此处安装一些适当的(Unix / Linux)工具,并按以下步骤操作:

paste -d" " file1 file2 file3
a b 1 2 e f
c d 3 4 g h
@echo off
setlocal EnableDelayedExpansion

3< File2.txt 4< File3.txt (
   for /F "delims=" %%a in (File1.txt) do (
      set "line1=%%a"
      set /P "line2=" <&3
      set /P "line3=" <&4
      echo !line1! !line2! !line3!
   )
)

Further details at this site . 该站点的更多详细信息。

  • You should use the batch-file tag for any "command prompt" related question. 您应该对任何与“命令提示符”相关的问题使用批处理文件标记。
  • You should upvote and select answers that had been useful to you, otherwise the people may refuse to answer your future questions. 您应该投票并选择对您有用的答案,否则人们可能会拒绝回答您将来的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM