Could anyone please help me to get solution for my below requirement. As i'm beginner to shell scripting, i don't have complete idea to achieve solution for below requirement. i tried "cut" and awk to split the file, then after that how we can search in table and to use that result to replace the string in file.
I'm using ksh.
I'm having abc.dat file with the content as below
EMP_ID|EMP_NAME|EMP_DEP|EMP_SAL
001|XXXX|D5|1000
002|YYYY|D5|2000
003|XXXX|D6|3000
004|AAA|D5|4000
I'm having a table DEP_TABLE as below
DPT_ID EMP_NAME EMP_DEP EMP_DES
01 XXXX D5 SSSS
02 YYYY D5 TTTT
03 XXXX D6 CCCC
04 AAA D5 HHHH
Here i want to find the record which having EMP_DEP
as D5
and need to select the coresponding EMP_des
from DEP_TABLE
(WHERE condition needs to use EMP_DEP, EMP_ID
) and that selected EMP_DES
need to replace EMP_DEP
IN file
1.find the record for a string in a field
2.search in table with the string
3. Replace the string with the new value found from table
EXPECTED OUTPUT
efg.dat file
EMP_ID|EMP_NAME|EMP_DEP|EMP_SAL
001|XXXX|SSSS|1000
002|YYYY|TTTT|2000
003|XXXX|D6|3000
004|AAA|HHHH|4000