Find and Replacement

Hi,

Im new to this forum, and also to Unix.

I have a requirement like this.

i have one DAT file that contains data as follows,

EMPNAME,
DEPT,
SALARY,
JOIN_DT,
DEDUCTION

i have one configuration file that contains data as follows,

SALARY
BONUS
DEDUCTION

i want a command that changes my DAT file as follows

EMPNAME,
DEPT,
0,
JOIN_DT,
0

i want a command the modifies the DAT file based on the configuration file.

Thanks in Advance

Use for (as for word in file) to get data one by one from configuration file ( if u have some delimiter , or \n then u can also use grep line by line ) and after u get the data use sed with substitute option.

For detail look into sed man page.

Can you tell me the syntax of the command for this solution

Could you show us how your configuration would look like ?

From what I understand

SALARY
BONUS
DEDUCTION

is the pattern of the configuration file. How does the configuration file with real data ?

Is it like this ?

0
10
0

or

SALARY=0
BONUS=10
DEDUCTION=0

vino

Thanks for responding

My configuration file will have one column and multiple rows. like this

SALARY
DEDUCTION
BONUS

I still dont know how your actual configuration files looks like. It would be better if you provide an actual sample of how it looks like.

In the mean time see if this suits you

[/tmp]$ echo "EMPNAME,
DEPT,
SALARY,
JOIN_DT,
DEDUCTION" | sed -e 's/SALARY/0/g' -e 's/DEDUCTION/0/g'
EMPNAME,
DEPT,
0,
JOIN_DT,
0

Vino