Hi Guys,
I have the following problem. I have original file (org.txt) that looks like this
module v_1(.....)
//arbitrary number of text lines
endmodule
module v_2(....)
//arbitrary number of text lines
endmodule
module v_3(...)
//arbitrary number of text lines
endmodule
module v_4(...)
//arbitrary number of text lines
endmodule
module v_5(...)
//arbitrary number of text lines
endmodule
I have another file keywords.txt that has keywords for original file org.txt that looks like
v_2
v_3
v_5
What i want to do is to extract modules from org.txt based on keywords.txt and store it in a new file (filter.txt). In this case, i shall be extracting only modules v_2, v_3 and v_5 and storing them in the filter.txt as
module v_2(....)
//arbitrary number of text lines
endmodule
module v_3(...)
//arbitrary number of text lines
endmodule
module v_5(...)
//arbitrary number of text lines
endmodule
How to do that using sed and awk or any other cool way. Note that this was a toy example. The actual files are huge in terms of number of lines.
Moderator's Comments:
|
|
Please use next time code tags for your code and data
|
|