How can I search a large file with 'sequential numbers' (that reset after 16) in a particular column to find a missing line?
I have a data file:
col1 col2 col3 col4 col5 1
col1 col2 col3 col4 col5 2
.
.
.
col1 col2 col3 col4 col5 15
col1 col2 col3 col4 col5 16
col1 col2 col3 col4 col5+1 1
where there last column counts from 1 to 16 then resets back to one. At this point 1 is added to column 5.
A clean output would just iterate up until the end of the file. How can I find missing data, e.g.
col1 col2 col3 col4 col5 1
col1 col2 col3 col4 col5 3
where a row has been skipped/lost as can be seen from the last column that has skipped the value of 2?
I'd like the line number/location of the line before or after the missing data as the desired output.
This answer on Stack Overflow gave me the idea to use awk. So what I've come up with is:
awk '$6!=p+1{print NR}{p=$6}'
To try and print the current line number when column 6 of the current line is not equal to column 6 of the last line +1. This fails due to the looping nature of getting to 16 and going back to 1.