Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Viewing all articles
Browse latest Browse all 102

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 102

Trending Articles



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