Finding exact match string

Hi All,

I'm writing unix script, it should find exact matching in search string. Looks simple but when i started i'm stuck to find the exact match character string.

The unix script reads the records from DB Table. The table will have values something likes these

Feed : A   Feed File name : feed_file_yyyymmdd.txt  
Feed : B   Feed file Name  : feed_file1_yymmdd.txt
Feed : C   Feed file Name  : feed_file2_yyyymmmdd.txt

For the Feed A, I have to look feed file name in "feed_file_20100630.txt", for B "feed_file1_100630.txt", for C "feed_file2_2010Jun30.txt". For the tomorrow month and Data gets changed (tomorrow is 1 Jul 2010).

After reading these values from DB, i have to find what format it has and replace with as of today's date format, look the file is exist in share folder.

I try to implement this with awk

awk ' {
/yyyymmdd/ { #case 1; next }
/yymmdd/    { #case 2; next }
#for all possible formats
}'

for the Feed B it goes to Case 1, but it suppose to go to Case 2.

If i reverse the order for the Feed A, it suppose to go to case 1, but goes to case 2.

I'm unable to achieve this using "-w" option in "grep" command.

I hope i have explained clearly.

Let me know how to resolve my problem

I don't know if I understood you correctly, but can't you do it like that?

awk ' {
/_yyyymmdd/ { #case 1; next }
/_yymmdd/ { #case 2; next }
#for all possible formats
}'

Actually in my example i have used "_" before for all date format. But actually some cases it is like (yyyymmdd_fee_file2.dat). In some cases it is like hh_mm_ss:yyyymmmdd also. So this wouldnt work out for my problem.

I have somehow close to my solution using the re interval option to awk. If some1 has better solution. Warm welcome for it.

echo $feed_file | awk --re-interval '
/y{3}ymmdd/ { print "yyyymmdd" }
/[^y]y{1}ymmdd/ { print "yymmdd" }
/yymmmdd/ { print "yymmmdd" }
/y{3}ymmmdd/ { print "yyyymmmdd" }
'

like this i will add complete possible cases. If any new format in feed file, i will be keep updating this script

Then try:

awk ' {
/yyyymmdd/ { #case 1; next }
/[^y]yymmdd/ { #case 2; next }
#for all possible formats
}'