bkiran
August 31, 2005, 11:50pm
1
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.
bkiran
September 1, 2005, 2:10am
3
Can you tell me the syntax of the command for this solution
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.
vino
September 1, 2005, 2:39am
4
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
bkiran
September 1, 2005, 3:38am
5
Thanks for responding
My configuration file will have one column and multiple rows. like this
SALARY
DEDUCTION
BONUS
vino:
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
vino
September 1, 2005, 3:51am
6
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