【发布时间】:2013-08-22 17:14:44
【问题描述】:
我有两个已排序的文本文件。文件 A 的数据如下所示:
adam
humanities
antwon
sciences
bernard
economics
castiel
sciences
dmitri
informatics
zoe
mathematics
文件 B 的数据如下所示:
adamburnston
antwonreed
justbernard
castiel
dmitrivalchenkov
zoematthews
我需要将文件 A(adam) 中的行替换为文件 B(adamburnston) 中的行。这两个文件都按字母顺序排列,并且包含相同数量的条目。我怎样才能达到这个结果?
预期输出:
adamburnston
humanities
antwonreed
sciences
justbernard
economics
castiel
sciences
dmitrivalchenkov
informatics
zoematthews
mathematics
【问题讨论】:
-
您的个人资料显示:
learning Python at the moment。为什么不使用它? -
@devnull - 因为有人明确要求我在 bash 中执行此操作。如果有选择,我会在 python 中尝试。
-
如果你经常被要求在 bash 中做一些事情(从你的previous 问题也可以看出,为什么不尝试学习呢?
-
你想用 bash 还是 awk 来做?
-
提问确实是学习的一部分。要求别人为你写不是。您必须尝试一下,然后返回您尝试过的代码,我们会帮助您修复它。