Hi, I'm not very familiar witrh sed or awk and hope the somebody can help me to solve my problem. I need to filter a text report using grep, sed or awk. I would like to cut out text lines with the pattern INFO and if exists the following lines of the pattern DETAILS. I need te keep the lines with the pattern DETAIL if in the lines before the pattern WARNUNG exists. The number of line with pattern WARNUNG, INFO and DETAILS can varry. Is this possible? If yes, how is the syntax?
Input Textfile example
Heading text 1
------------------------------------
WARNING text
WARNING text
INFO text1
INFO text1
INFO text2
DETAILS text (Info)
DETAILS text (Info)
DETAILS text (Info)
Heading text 1
------------------------------------
INFO text1
WARNING text
WARNING text
DETAILS text (warning)
DETAILS text (warning)
WARNING text
DETAILS text (warning)
DETAILS text (warning)
DETAILS text (warning)
Heading text 1
------------------------------------
INFO text1
DETAILS text (Info)
DETAILS text (Info)
INFO text (Info)
WARNING text
DETAILS text (warning)
Output Needed
Heading text 1
------------------------------------
WARNING text
WARNING text
Heading text 1
------------------------------------
WARNING text
WARNING text
DETAILS text (warning)
DETAILS text (warning)
WARNING text
DETAILS text (warning)
DETAILS text (warning)
DETAILS text (warning)
Heading text 1
------------------------------------
WARNING text
DETAILS text (warning)
In need to show only the following lines_
- Line with heading text
- Line with the underlining of the heading test
- Line with WARNING pattern
- Line with DETAILS pattern, only when in lines above the pattern WARNING exists. The number of the lines with DETAILY can vary.
Thanks