Q:

Using awk to find missing field in line

I have several thousand line file that lists directories where data gets deposited every fifteen minutes.  Each directory's name is a timestamp that ends with either 00, 15, 30, or 45.
This file contains each timestamp with the fifteen minute intervals that are present.  For example,
io_credit 2014030100 00 15 30 45
io_credit 2014030101 15 30
io_credit 2014030102 45
io_credit 2014030103 00 15 30 45

As you can see some timestamps are missing certain fifteen minute intervals.  Also note that the order in which the timestamps are written is always the same, even if a timestamp is missing.  So if 15 is the only timestamp missing then 00, 30, and 45 will be in order.  Sames holds true for all other timestamps.  So in other words you'll never see something like
45 15 30

I've been struggling with awk to figure out some way of print out each timestamp and the missing interval(s) for that timestamp.
Below is what I've written for lines that contain only five fields:
cat file | awk '{if (NF == 5) for (i = 3; i <= 5; i++) { if (i == 3 && $i == "00") continue; else if (i == 3 && $i == "15") missing="00"; continue; if (i == 4 && $i == "15") continue; else if (i == 4 && $i == "30") missing=missing " 15"; if (i == 5 && $i == "30") missing=missing "45"; else missing=missing "30"; } {print $1,$2, missing }}'

However this only prints "00" and nothing else for every line that matches the (NF == 5) qualifier.
What am I doing wrong here?

A:

The following looks at each line in the file.  If the line has all the timestamps, it is ignored.  If not, the missing timestamps are printed:
$ awk 'NF==6 {next} {c="00 15 30 45"; for(i=3;i<=NF;i++){sub($i,"  ",c)}; print $2" " c} ' file
2014030101 00       45
2014030102 00 15 30  

How it works:  If all timestamps are present on a line, then that line has 6 fields.  All likes with six fields (NF==6) are ignored.  Otherwise, the variable c is set to "00 15 30 45".  Then, the code loops through each of the time stamps and, if present, removes it from c.  The timestamp and whatever remains in c (which would be the missing fields) is printed.

