I am trying to take a text file called 'input', of the form
line1
line2
line3
PATTERN
x y z
x y z
lineN
and use awk to place a number (1) after each "x y z" line. I need the lines before the PATTERN and after the "x y z' lines (lineN) in the output. The output I needs looks like this:
line1
line2
line3
PATTERN
x y z 1
x y z 1
lineN
What I have so far is:
awk '/PATTERN/ {getline; print $0 " 1" }' < input > output
This gives:
x y z 1
Is it possible to set up a loop to get awk to append an arbitrary number of "x y z" lines or stop after the "x y z" type lines finish?