Check the exact month and date

Hi All,

Please help me in the below code.

 awk -v pattern="$_month$Day" 'BEGIN {FS = "." }; {if ($3~pattern) {print $0}}' ${BASE_DLY_UOGL_WORK_DIR}/Avail_ApprovedReports.txt > ${BASE_DLY_UOGL_WORK_DIR}/Reqd_ApprovedReports.txt 

the above code will take the current month and date (i.e pattern ='0102' and searches in the 3 column (i.e 20130101024056) from the file xx.txt.20130101024056.gz

But the above code works wrongly since today's date is 0102 and it should check 20130101024056 and if there is no match it means there is no file for today.
But it is searching the entire column and if matches it is processing that file.(i.e 20130101024056)
Please help me in the code to check only required month and date (0101) from the 3rd column of the file.

Thanks,
Kiran

Use awk substr function:

if(substr($3,5,4)==pattern)

Or, extend pattern to contain the year as well: pattern="20130102"