Explanation: for each line I append to value under key shown in 1st filed ($1) space and 2nd field ($2), if it was not yet present, space followed by content of 2nd field is place. After all lines are processed for each key in array I printf that key and value under that key, note that space is not required in 1st argument as it is already 1st character of each value.
发布评论
评论(1)
我将使用gnu
awk
进行此任务以下方式,让input1.txt
content beand
input2.txt2.txt
be be提供
输出
说明:我将每行我附加到第1个提交中显示的密钥(
$ 1
)和第二个字段($ 2
),如果尚不存在第二场是地方。在对数组中的每个键处理所有键iprintf
该键下的所有键后,请注意第一个参数中不需要空格,因为它已经是每个值的第一个字符。(在GAWK 4.2.1中测试)
I would use GNU
AWK
for this task following way, letinput1.txt
content beand
input2.txt
content bethen
gives output
Explanation: for each line I append to value under key shown in 1st filed (
$1
) space and 2nd field ($2
), if it was not yet present, space followed by content of 2nd field is place. After all lines are processed for each key in array Iprintf
that key and value under that key, note that space is not required in 1st argument as it is already 1st character of each value.(tested in gawk 4.2.1)