Combining multiple files

I have 2 files.
each having 3 coloums
1st field date as 20130322
2nd field time as 05:55
3rd field numberic value

File 2 has entries missing for some date time.

FILE1 
20130322     05:35    2219 
20130322     05:40    1809 
20130322     05:45    1617 
20130322     05:50    1359 
20130322     05:55    2233 
20130322     06:00    1648 
20130322     06:05    1552 

FILE 2

20130322     05:35    170 
20130322     05:40    169 
20130322     05:45    172 
20130322     05:50    171 
20130322     06:05    176 

I want to join these 2 files and put zeros for missing values
o/p should look like :

                      FILE1           FILE2
20130322     05:35    2219              170  
20130322     05:40    1809              169  
20130322     05:45    1617              172  
20130322     05:50    1359              171  
20130322     05:55    2233                0
20130322     06:00    1648                0
20130322     06:05    1552             176 

Thanks in advance ..

Please search the forum before you post

You could try something like:

awk '
FNR == 1 {   
        f[++fc] = FILENAME
        if(w[fc] < length(FILENAME)) w[fc] = length(FILENAME)
}
FNR == NR {
        d[++lc] = $1
        t[lc] = $2
}
{       v[fc,$1,$2] = $3
        if(w[fc] < length($3)) w[fc] = length($3)
}
END {   printf("    Date  Time")
        for(j = 1; j <= fc; j++)
                printf("%*s%s", w[j] + 1, f[j], j == fc ? "\n" : "")
        for(i = 1; i <= lc; i++) {
                printf("%s%6s", d, t)
                for(j = 1; j <= fc; j++)
                        printf("%*d%s", w[j] + 1, v[j, d, t],
                                j == fc ? "\n" : "")
        }
}' FILE[12]

If you are running on a Solaris/SunOS system, use /usr/xpg4/bin/awk or nawk instead of awk .

Note that this script will work for two or more files, but the 1st file given must include all date/time pairs that you want to appear in the output.

With the FILE1 and FILE2 contents specified in the 1st message in this thread, the output produced by this script is:

    Date  Time FILE1 FILE2
20130322 05:35  2219   170
20130322 05:40  1809   169
20130322 05:45  1617   172
20130322 05:50  1359   171
20130322 05:55  2233     0
20130322 06:00  1648     0
20130322 06:05  1552   176