Can someone please explain the strange behaviour.. I was just trying a few things to learn awk..
in the below code when I start the braces in the same line, the output is as expected, when I start at next line, output is displayed twice.
Please see the file, code I tried and output below.
File contents:
cat d_exp
BEG
Id Job1
Id Stage1
1
EN
Id Job2
Id Stage2
BEG
Id2 Job3
Id Stage4
2
EN
awk '/BEG/,/EN/ {
print
}' d_*
-- Output as expected
BEG
Id Job1
Id Stage1
1
EN
BEG
Id2 Job3
Id Stage4
2
EN
Braces in next line
awk '/BEG/,/EN/
{ #Next line
print
}' d_*
BEG
BEG
Id Job1
Id Job1
Id Stage1
Id Stage1
1
1
EN
EN
Id Job2
Id Stage2
BEG
BEG
Id2 Job3
Id2 Job3
Id Stage4
Id Stage4
2
2
EN
EN
Everyline is printed twice in the above output
Can someone please explain this? What am I missing here?