【发布时间】:2020-01-08 09:02:36
【问题描述】:
我想复制一个文本文件中的所有文本并添加到另一个文本文件中的每一行的开头。
我尝试过使用 sed,我可以在每行的开头放置一个字符,但我不知道如何从另一个文件中复制文本
我试过这个:
sed 's/^/#/' 2.txt > 3.txt
但这只会放一个字符或字符串。
例子:
我在 2.txt 中有这样的话:
u
ubbia
ubbidiente
ubbidienza
ubbidire
ubertoso
在第二个 3.txt 我有相同的行但有解释:
u = explanation here
ubbia = explanation here
ubbidiente = explanation here
ubbidienza = explanation here
ubbidire = explanation here
ubertoso = explanation here
我想要这个结果:
u u = explanation here
ubbia ubbia = explanation here
ubbidiente ubbidiente = explanation here
ubbidienza ubbidienza = explanation here
ubbidire ubbidire = explanation here
ubertoso ubertoso = explanation here
【问题讨论】:
-
paste 2.txt 3.txt > combined.txt可能适合您。它将在不同内容之间的每一行上包含一个制表符字符。如果你真的需要它完全对齐,你可以在中间添加类似awk '{printf "%15s\t%s\n", $1, $2}'的东西。祝你好运。