Using sed to pattern match within a particular multiline block and take action

view story

http://www.unix.com – Hi all, This is my first post, so please go easy if I broke some rules. Not accustomed to posting in forums... :) I'm looking for help on pattern matching within a multiline block and looking to highlight blocks/block-ids that do NOT contain a particular pattern. For example an input file might contain the following: Code: fruit APPLE   blah1   PATTERN   blah2 fruitend fruit ORANGE blah1 blah2 blah3 fruitend fruit KIWI PATTERN blah1 blah2 fruitend In the above case, I would like the block of ORANGE or the keyword ORANGE printed, since the recognized pattern was n (HowTos)