Quote:
current=$NF defines that the line read at the moment is stored as a variable called NF so when the next line is read it can compare the new current line with the line before.
|
Incorrect. NF is the Number of Fields in a row which is determined by the FS (Field Separator), which as you have not changed it is the default of any contiguous white space.
So in the example, current is being set to the value of whatever is stored in the last field. So in your example data the first line would store the number 3 in current as it is the last field.
Quote:
++ is the same as +1 right?
|
Correct:
Code:
count++
# is the same as
count = count + 1
So you are kind of on the right track but need to see my information above about NF.
Assuming your syntax was right, which it currently is not, if you issue the following:
Code:
awk 'NR > 1 && $NF != current{count++}{current = $NF}NR == 1{next}END{print count}' file
See if that helps you in the correct direction.