copy the contents between two keywords to a new file.

Hi All,

I want to edit my gate level netlists by searching for the content between two patterns

eg:

ff1 \test/a0 ( .CLK(\test/ClkInt0_acb_00x1 ),.D(\test/Rakicc ), .QB(\test/X [1]), .VDD(1'b1), .VSS(1'b0));
ff1 \test/a1 ( .CLK(\test/medis0_acb_00x1 ),.D(\test/hedwc ), .QB(\test/X [1]), .VDD(1'b1), .VSS(1'b0));
ff1 \test/a2 ( .CLK(\test/tergus_acb_00x1 ),.D(\test/Ddec ), .QB(\test/X [1]), .VDD(1'b1), .VSS(1'b0));
.....
.....

i need to grep the contents after ".CLK(" and before "),.D" and copy it to a new file.

Kindly help me with this.

Thanks a bunch
naveen

To keep the forums high quality for all users, please take the time to format your posts correctly.

  1. Use Code Tags when you post any code or data samples so others can easily read your code.
    You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags and by hand.)
  2. Avoid adding color or different fonts and font size to your posts.
    Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
  3. Be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
Reply With Quote

sed 's/.*CLK(\(.*\) ),\.D.*/\1/' file

thanks a lot danmero
i am new to shell scripting. Kindly help me with this if possible.

now that i have my list I need to replace them as follows

inv in_0 (.A(\test/ClkInt0_acb_00x1 ),.VDD(VDD),.VSS(VSS),.Z(i_0)); 
nand nd2_0 (.A(i_0), .B(VDD),.VDD(VDD),.VSS(VSS),.Z(nd_0));
ff1 \test/a0  ( .CLK(nd_0),.D(\test/Rakicc ), .QB(\test/X [1]), .VDD(1'b1), .VSS(1'b0), .A(tmp_0), .B(tmp_1) ); 

inv in_1 (.A(\test/medis0_acb_00x1 ),.VDD(VDD),.VSS(VSS),.Z(i_1)); 
nand nd2_1 (.A(i_1), .B(VDD),.VDD(VDD),.VSS(VSS),.Z(nd_1));
ff1 \test/a1  ( .CLK(nd_1)),.D(\test/hedwc ), .QB(\test/X [1]), .VDD(1'b1), .VSS(1'b0),.A(tmp_1), .B(tmp_2) );

nv in_2 (.A(\test/tergus_acb_00x1 ),.VDD(VDD),.VSS(VSS),.Z(i_2)); 
nand nd2_2 (.A(i_2), .B(VDD),.VDD(VDD),.VSS(VSS),.Z(nd_2));
ff1 \test/a2  ( .CLK(nd_2)),.D(\test/Ddec ), .QB(\test/X [1]), .VDD(1'b1), .VSS(1'b0),.A(tmp_2), .B(tmp_3) ); 
......
.......

I am using a lengthy workaround. i Initially generate a list using

#!/bin/bash
i=$1
while [ $i -lt $2 ]; do
j=$(($i+1))
echo "nv in_$i (.A(),.VDD(VDD),.VSS(VSS),.Z(i_$i)); 
 nand nd2_$i (.A(i_$i), .B(VDD),.VDD(VDD),.VSS(VSS),.Z(nd_$i));
(.CLK(nd_$i)),.D(), .QB(), .VDD(1'b1), .VSS(1'b0),.A(tmp_$i), .B(tmp_$j) ); "  >> temp_list.v
i=$(($i+1))
done

and then i manually replace other data. Could anyone help me with an easier workaround please?

Thanks again
Naveen

bash

while read -r line
do
    case $line in 
        *CLK\(* ) 
            line=${line#*CLK\(}
            line=${line%.D(*}
            echo $line
            ;;
    esac    
done < "file"

Hi All,
Could someone help me with the issue I have posted..

Thanks a lot

Don't bump your question and try to explain what's the relationship between your first and second post.

Hello....
Can someone out there help me with some shell scripting for the problem posted above????

Thanks a lot..
Naveen