I am trying to find missing dates in a log file. Essentially, I have 2 input files, an 'eventlist' and an 'eventlog' that look like this:
eventlist
EV01 Event number one
EV02 Event number two
eventlog
2014-09-14 EV01
2014-09-16 EV01
2014-09-20 EV01
2014-09-21 EV01
2014-09-22 EV01
2014-09-23 EV01
2014-09-24 EV01
2014-09-25 EV01
2014-09-14 EV02
2014-09-22 EV02
2014-09-23 EV02
2014-09-24 EV02
2014-09-25 EV02
I am trying to see the number of consecutive days (from today) that I have eventlog records for. Based on the file above, I would like the output below:
6 Event number one
4 Event number two
So far I have the script below, but it returns me a count of occurrences for each event:
awk 'NR==FNR { a[$1]=$0; next }{print $1,a[$2]}' eventlist eventlog | awk '{print substr($0, index($0, $3))}' | awk -F, '!z[$1]++{ a[$1]=$0; } END {for (i in a) print z[i], a[i]}'
This currently returns:
8 Event number one
5 Event number two
Any ideas on how I can modify the above to show me the number of sequential days (up to today) instead of a total count?