在包含单个列值的多个文件中查找共同值 [英] Finding common value across multiple files containing single column values

查看:67
本文介绍了在包含单个列值的多个文件中查找共同值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有100个文本文件,每个文本文件都包含一列.这些文件如下:

I have 100 text files containing single columns each. The files are like:

file1.txt
10032
19873
18326

file2.txt
10032
19873
11254

file3.txt
15478
10032
11254

,依此类推. 每个文件的大小是不同的. 请告诉我如何找到所有这100个文件中的通用编号.

and so on. The size of each file is different. Kindly tell me how to find the numbers which are common in all these 100 files.

出现相同的数字1个文件中只有一次.

推荐答案

awk进行救援!

查找所有文件中的公共元素(假设同一文件中的唯一性)

to find the common element in all files (assuming uniqueness within the same file)

awk '{a[$1]++} END{for(k in a) if(a[k]==ARGC-1) print k}' files

计算所有出现的次数,并在count等于文件数的情况下打印值.

count all occurrences and print the values where count equals number of files.

这篇关于在包含单个列值的多个文件中查找共同值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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