Sunday 4 August 2019

AWK print next line of match between matches

Let's presume I have file test.txt with following data:



.0

41
0.0
42
0.0
43
0.0
44
0.0
45
0.0

46
0.0
START
90
34
17
34
10
100
20

2056
30
0.0
10
53
20
2345
30
0.0
10

45
20
875
30
0.0
END
0.0
48
0.0
49

0.0
140
0.0


With AWK how would I print the lines after 10 and 20 between START and END.
So the output would be.



100
2056

53
2345
45
875


I was able to get the lines with 10 and 20 with



awk '/START/,/END/ {if($0==10 || $0==20) print $0}' test.txt 



but how would I get the next lines?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...