Quote:
I was wondering if it made a difference when I left out the next commands?
I know that next makes awk read the next line and start with the script from beginning, but exactly that happens even if I leave out "next", right?
|
The script will continue using
the same line of input text.
So, using your example
Code:
/EXPRESSION/ { variable=5; next}
/EXPRESSION2/ {variable2=6; next}
Say, the current line of text matches EXPRESSION. Then the next line of text will be read, on which the script will start processing from the start.
So the second line of code will not be executed when EXPRESSION matches the current line. Thus variable2 will
never be assigned 6, even if EXPRESSION2 matches the same line.
If this script is the whole script, "next" in the last line of code will not make a difference, as after executing the last line of the script, awk will start the script from the start on the next line of text anyways.