I have multiple sections, each consisting of multiple lines.e.g:#--- Section 1 ---Start  Lookup.mdc|123|xyz|  String  End#--- Section 2 ---Start  Lookup.mdc|123|xyz|  Integer  End  My requirement is: I need to extract only that section which contains Integer(Datatype search) in it.Expected Output:  Start  Lookup.mdc|123|xyz|  IntegerEnd
Extract specific section
text processing
awk 'BEGIN {RS=^--- Section [0-9]+} /Integer/ {print}'and either pipe the input into it, or add the filename onto the end.You don't need the {print}, as that is the default action, but I put it in to make it clearer.The BEGIN is executed before the input is processed, and sets the magic variable RS (Record Separator) to match the line which separates records.The /Integer/ matches records which contain Integer.