The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 -->
  #1 (permalink)  
Old 05-27-2009
shalini_008 shalini_008 is offline
Registered User
  
 

Join Date: May 2009
Posts: 4
Post Issue with awk script

Hi ,

I am using the below awk script

awk '{if($0 ~ /B1/) {set=1; next }; if( $0 ~ /END/) {set = 0}; if (set ) { print }}' CODE | awk '/A \(P1\)/{f=1}f && /}/{print; system("cat $1");f=0;next}1' A.lib > newfile

I need to insert code from CODE file into A.lib file

A.lib file content is

A (P1) {

timing : 10;
cap : 2;
slew : 3;
}
C (P2)

time : 10;
cap : 2;
slew : 3;

}

D (P3)

time : 11;
cap : 4;
slew : 6;
}

A (P1) {

time : 16;
cap : 4;
slew : 7;
}

I could able to enter the code from CODE file while searching the patterns A (P1) but it is not inserting the code for another Block

A (P1) {

time : 16;
cap : 4;
slew : 7;
}

My issue is with Global Replacement with this script whereever it can find A (P1) it should insert the code from CODE file .

I tried to use the g operator but it is not working


Please advice in regards with the same

Thanks
Shalini