Chinaunix's Archiver
论坛
›
Perl
› linux下如何查找两个文本中的相同内容?
小鬼啊不
发表于 2015-08-10 16:35
MMMIX
发表于 2015-08-10 18:04
回复 1# 小鬼啊不
方法之一, 用第一个文件的内容构建一个 hash, 键为列, 值为行. 然后读取第二个文件, 使用其列在上述hash中查找, 找到了就输出对应的行.
sunzhiguolu
发表于 2016-09-09 13:22
perl -ane 'if(@ARGV){push(@a,$_);next}print "$r$_" if(($r)=grep{local $"="|";$_=~/@F/}@a)' a b
01 abd
11c aj
04 npq
13r pq
页:
[1]
查看完整版本:
linux下如何查找两个文本中的相同内容?