Quantcast
Channel: Filter lines between matching strings - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2

Filter lines between matching strings

$
0
0

Have a contents in file similar to below- There are many lines between START & END and might have errors/warnings too. I want to filter out errors/warning lines between START & END and skip if doesn't have. Heading is varying with different names. But make logic of printing next line of START(should be heading)

START
Heading1
.......
errors
........
END

START
Heading2
........
........
........
END

START
Heading3
.......
errors
Warning...
END

Expected output below

Heading1
errors

Heading3
errors
Warning...

I have tried below , but this prints everything between START & END . I have to filter out errors too

awk '/START/,/END/' file

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>