【发布时间】:2014-05-12 09:19:40
【问题描述】:
我有一个文件 file1,其内容为以下模式,由空行分隔的一组行。
First line
line1
Line2
abc
def
jkl
123456
opertxt
this is line
this is sentence
this is last line
我在下面的格式中有另一个平面文件 2。 file2中的eact行对应file1中的行组。
group1
group2
group3
group4
group5
我想同时读取这两个文件并重复 file2 中的行。我将输出重定向到file3。我想要文件 3 看起来像这样。
group1
group2
group2
group3
group3
group3
group4
group4
group5
group5
group5
所以最后 file1(不包括空白行)和 file3 中的行数将相同。 有人可以建议使用 ksh 或 awk, sed 的解决方案吗?
【问题讨论】: