【问题标题】:UNIX iterating through .txt files and merge them by line into a single fileUNIX 遍历 .txt 文件并将它们逐行合并到一个文件中
【发布时间】:2019-08-10 10:44:45
【问题描述】:

假设我在 UNIX shell 上有 3 个不同的 .txt 文件。我想将不同的文件合并为一个文件。我还需要逐行创建和写入该文件。

举个例子:

file1.txt:

-abc

-定义

-ghi

file2.txt:

-123

-456

-789

file3.txt:

-***

-^^^

-'''

我需要以这种格式写入并保存组合文件:

combinedFile.txt

abc 123 ***

定义 456 ^^^

ghi 789 ´´´

【问题讨论】:

  • man paste ...

标签: shell file unix merge iteration


【解决方案1】:

剪切,示例:

cut -d- -f2 file1 > file11

粘贴,示例:

paste -d' ' file11 file22 file33

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-20
    • 2022-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多