统计两个文件中相同行的数目
来源:互联网 发布:jy网络上是什么意思 编辑:程序博客网 时间:2024/04/29 19:22
#!/usr/bin/perl
#================================================================================================================
#Author:huangyunhao
#Date:2010-12-10
#Function:count the number of the same lines between two lines containing a IP every line and the IP number in every file.
#Usage:perl two_files_insect.pl <flie1> <file2>
#================================================================================================================
use strict;
use warnings;
my %hash;
my $line_n=0;
open(FILE,'<',$ARGV[0]) || die "Cannot open $ARGV[0]:$!";
while(<FILE>){
$line_n++;
chomp;
$hash{$_}=1;
}
close FILE;
print "The IP number in the first file:$line_n/n";
$line_n=0;
my $number=0;
open(FILE,'<',$ARGV[1]) || die "Cannot open $ARGV[1]:$!";
while(<FILE>){
$line_n++;
chomp;
$number++ if(exists $hash{$_});
}
close FILE;
print "The IP number in the second file:$line_n/n";
print "The number of same IP:$number/n";
- 统计两个文件中相同行的数目
- linux 统计两个文件中相同或不同的行
- Java对比两个文件统计字符串相同行的数量
- 找两个文件中相同的行
- 输出两个文件中不同/相同的行
- 使用shell 统计文本行数,输出两个文件不同或相同的行
- python 统计文件中单词数目
- Linux 统计当前文件夹、文件的数目
- Linux统计文件夹下的文件数目
- Linux统计文件数目
- 统计字符串中字符种类的数目
- 查找两个文件中相同的单词stl
- 两个10G的文件中,求含有相同整数
- 08年华科机试第二题(统计文件中单词的数目)
- 计算一个数组中相同元素对的数目
- java统计文件中字符,数字,汉字,空格数目
- java统计文件中字符,数字,汉字,空格数目
- 统计1的数目
- GDI函数执行成功与否的检验方式
- linux内核调试平台与内核调试技术
- 数据结构_2.单链表
- SQL Server 表变量与临时表区别
- 判断求和格式化输出
- 统计两个文件中相同行的数目
- CSS样式在IE6下无效的问题解决方案(编码问题)
- hangye5:2345导航确认巨人和红杉参与投资 并非收购
- 无聊
- GTK+ 2.0 Tutorial http://library.gnome.org/devel/gtk-tutorial/stable/
- 找资料真的那么难?
- 最近比较流行的界面欣赏
- hangye5:2345网址导航百万重金求顶尖人才 意在扩展高端用户人群
- 快速启动任意程序