The UNIX and Linux Forums  

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




Thread: Sed Range Issue
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 06-05-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,315
Try this:

Code:
awk ' 
FNR==NR && /descriptor2/{f=1} 
FNR==NR && /descriptor4/{f=0} 
FNR==NR && f{arr[++i]=$0}
FNR==NR{next}
/descriptor2/{for(j=1;j<=i;j++){print arr[j]};f=1} 
/descriptor4/{f=0} 
!f{print}
' "file1" "file2"
Regards