合并多个文件 [英] join multiple files

查看:129
本文介绍了合并多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用标准的join命令来连接两个基于column1的已排序文件. 命令是简单的连接文件1文件2>输出文件.

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_file Above 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

这篇关于合并多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆