问题描述
我使用标准连接命令连接基于 column1 的两个排序文件.命令是简单的 join file1 file2 > output_file.
I am using the standard join command to join two sorted files based on column1.The command is simple join file1 file2 > output_file.
但是我如何使用相同的技术连接 3 个或更多文件?加入 file1 file2 file3 > output_file上面的命令给了我一个空文件.我认为 sed 可以帮助我,但我不太确定如何?
But how do I join 3 or more files using the same technique ?join file1 file2 file3 > output_fileAbove command gave me an empty file.I think sed can help me but I am not too sure how ?
推荐答案
man join
:
NAME
join - join lines of two files on a common field
SYNOPSIS
join [OPTION]... FILE1 FILE2
它仅适用于两个文件.
如果你需要加入三个,也许你可以先加入前两个,然后加入第三个.
if you need to join three, maybe you can first join the first two, then join the third.
试试:
join file1 file2 | join - file3 > output
应该在不创建中间临时文件的情况下加入三个文件.-
告诉 join 命令从 stdin
that should join the three files without creating an intermediate temp file. -
tells the join command to read the first input stream from stdin
这篇关于加入多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!