The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 11-23-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,098
perl:

Code:
open FH,"<d:/a.txt";
while(<FH>){
	if(m/^1.*/){
		$line=$_;
		print;
		next;
	}
	if(m/^6.*/){
		@t=split;
		if($temp eq ""){
			$temp=$t[3];
			print;
		}
		else{
			if(!($t[3] eq $temp)){
				print $line;
				print $_;
				$temp=$t[3];
			}	
			else{
				print;
			}		
		}
	}
	else{print;}
}