Match pattern and replace

Hi All,

I am new to unix shell scripting, I need your help guys in coming up with some thing for the following scenario:

file1

ABC_BASE ${base}
ABC_ACC ${acc}
ABC_TEST ${test}
01-01-2006 ${from_dt}
01-15-2006 ${to_dt}

file 2

I have an file2.sql file which contains:

####This resides in .sql file ----------------------------------------------

INSERT INTO /*<base>*/ABC_BASE.tablename

SELECT
col1, col2

FROM
 /*<acc>*/ABC_ACC.tablename2

WHERE
          so_dt >= /*<from_date>*/'01-01-2006'
      AND
          so_dt < /*<to_date>*/'01-15-2006'

file3.sql

####This is the desired output--------------------------------------

INSERT INTO /*<baseDB>*/${base}.${xyz}${def}_tablename

SELECT
 col1, col2

FROM
 ${acc}.ABC_ACC.tablename2

WHERE
          so_dt >= /*<from_date>*/'${from_dt}'
      AND
          so_dt < /*<to_date>*/'${to_dt}'

The tags are commented, by using tags we have to match the pattern and replace as above.

This is the opposite of the regualr stuff

Thanks for you time guys... waiting for ur answers

---------- Post updated 09-01-09 at 11:16 AM ---------- Previous update was 08-31-09 at 09:41 PM ----------

Any ideas please

Are you looking for a script that will *create* the .sql file new each time that is run with the 7 variables that you are assigning?
Where are you getting the 7 variables?
Is it part of a larger script?

Yep I am looking for a script that will generate the new .SQL file when we give the original SQL file as input. And the variables will be in a list file

The list file - can you provide an example?
It makes a difference it it's one field per line, or if the fields are on a single line separated by commas or spaces, etc. Also, if there are multiple records or sets, is there space between the records? A little more information is required...

Say we have a list file with the following

file1

ABC_BASE ${base}
ABC_ACC ${acc}
ABC_TEST ${test}
01-01-2006 ${from_dt}
01-15-2006 ${to_dt}

file 2

contains the sql

My idea is, it has to match with the tags and replace apporopriately, I mean like
search for /*<base>*/ and replace the ABC_BASE with ${base} from the list file1

---------- Post updated 09-02-09 at 01:28 PM ---------- Previous update was 09-01-09 at 05:05 PM ----------

It has to find the pattern from the list file and replace accordingly

---------- Post updated at 11:05 PM ---------- Previous update was at 01:28 PM ----------

I have tried using sed, but I am not getting how to get it from the file1