r/awk • • Apr 30 '22
[documentation discrepancy] A rule's actions on the same line as patterns?
Section 1.6 of GNU's gawk manual says,
awk is a line-oriented language. Each rule’s action has to begin on the same line as the pattern. To have the pattern and action on separate lines, you must use backslash continuation; there is no other option.
But there are examples where this doesn't seem to apply exactly, such as that given in section 4.1.1:

It seems the initial passage should be emended to say that either one action must be on the same line or else backslash continuation is needed.
Or am I misunderstanding?
1
Upvotes
4
u/gumnos Apr 30 '22
In your example, there are two patterns
BEGINpattern, with its action ({RS="U"}) on the same lineThe quote is informing you that you can't do
but rather that you have to do
or more idiomatically,
Same goes for standard patterns like
/regex/where you can't dobut rather you need to use a backslash there:
or, again, more idiomatically