When learning to use awk
, I found the expression awk 'c&&!--c;/regex/{c=N}'
as a way to select and print the N
th line below the line matching the regex. I understand that c
is initially equal to 0
so the first match isn't printed but despite having searched high and low, I don't know how to interpret the remaining syntax (outside of the /regex/
) and how it specifically knows to count N
lines before printing.
Can someone explain what c&&!--c
means and how it works as a counter with the rest of the function?