【发布时间】:2019-12-21 10:56:06
【问题描述】:
我有两个文本文件:
文件 1 - 连接 ID、主机、IP
File2 - ConnectionID、DestType、DestName、计数
我想将两个文件中匹配的 ConnectionID 打印为 ConnectionID,Host,IP,DestType,DestName,Count 并从两个文件中分别吐出不匹配的行。
示例数据:
文件 1:四行
1,serverA,1.1.1.1
2,ServerA,1.1.1.1
3,ServerB,1.1.1.2
4,ServerC,1.1.1.3
文件 2:三行
1,Q,Dest1,10
3,T,Dest2,20
5,T,Dest3,45
想要的输出为:
1,ServerA,1.1.1.1,Q,Dest1,10
3,ServerB,1.1.1.2,T,Dest2,20
2,ServerA,1.1.1.1,null,null,null
4,ServerC,1.1.1.3,null,null,null
5,null,null,T,Dest3,45
我想要使用 awk、Perl、sed 等的 Unix 命令。
这就像在数据库中:
select columns from table a, table b where a.ConnectionID=b.ConnectionID
还有内连接和外连接
所有结果作为输出
【问题讨论】:
-
感谢您更新问题。使其更易于阅读。