Reputation: 93
I'm trying to extract some text in a passage that is between two strings that are being saved in variables. What is wrong with the following way?
module dft ( a, b, c, clk, z, test_si, test_se );
input [7:0] a;
dft_DW_mult_uns_1 mult_31 ( .a(a), .b(b), .product(reg0) );
endmodule
input [7:0] a;
dft_DW_mult_uns_1 mult_31 ( .a(a), .b(b), .product(reg0) );
using the following code:
try="module dft";
awk '/$try/{flag=1; next} /endmodule/{flag=0} flag' dft_syn.v
but it doesn't recognize the $try variable.
Upvotes: 3
Views: 117
Reputation: 784898
You can use awk
like this:
sm="module dft"
em="endmodule"
awk -v sm="$sm" -v em="$em" '$0 ~ em{p=0} p; $0 ~ sm{p=1}' file
...which property emits as output:
input [7:0] a;
dft_DW_mult_uns_1 mult_31 ( .a(a), .b(b), .product(reg0) );
-v var="value"
to pass command line variables from shell to awk
p
when you encounter start or end tagsUpvotes: 2