perl -ne 'print if 8..12
先提取指定范围的内容
#!/usr/bin/perl open($fh,'<',"1.txt") or die $!; open($fhout,">2.txt"); while ($line=<$fh>) { @tmp = split(/ /,$line); @tmp1 = split(/-/,$tmp[0]); if ( $tmp1[0] == 2017 ) { $mLineFlag =0; //multiple regular condition,use | if ($line =~ (/H323Proxy|SIGNAL|MC/) ) { $mLineFlag =1; print $fhout $line; } } else { if ($mLineFlag) { print $fhout $line; } } } close $fh; close $fhout;