I have a simple awk one liner that folds the next line onto the current line when a given pattern is matched. Here it is:
awk '/two/ { printf $1; next; } 1' test.txt
with the following input:
one
two
three
four
five
six
one
two
three
four
you get:
one
twothree
four
five
six
one
twothree
four
Note that the "three" is folded up with the "two" which is what I wanted to occur. I found this solution (don't remember where) and thought it odd that the trailing '1' appeared to be the missing piece that resulted in the desired effect. If you take it out, you get:
awk '/two/ { printf $1; next; }' test.txt
twotwo
As the result. So my question is, what does the trailing '1' do, and where is it documented?
Thanks!