Reputation: 1
Using awk, how to find out the discontinuity in series of data. I have got data like below.
Example: Input data:
shotline shot
1001 1001
1001 1002
1001 1003
1001 1005
1001 1006
1001 1009
1002 1001
1002 1003
Data should be:
Missing data points:
1001 1004
1001 1007
1001 1008
1002 1002
Upvotes: 0
Views: 264
Reputation: 723
Here is a working solution:
cat data | awk '{shotline = $1; if(shotline != last_shotline){last_shotline = shotline; last_shot = 1000;} shot = $2; while(shot != last_shot+1){ last_shot = last_shot+1; print shotline " " last_shot }; last_shot = shot;}'
Upvotes: 1