value in file - manipulation

Hi Forum.

I have the following 2 files: edw_mf_bypass_msg.txt and EDW_server.cfg.

edw_mf_bypass_msg.txt - File#1 contains the following text

To EDW Support:
 
This is an automatic email sent from var_hostname.
 
Please note that the Mutual Fund load did not run today due to previous data issues.
 
After the fix, simply run 'EDW_JOBS.JX_Enable_MF_Load' to enable the load again.
 
Thank you.

EDW_server.cfg - File#2 contains 1 line entry:

newdwdev

I need to replace string "var_hostname" from file#1 with "newdwdev" from file#2.

How can it be done easily?

thank you.

#!/usr/bin/ksh
mValue=$(cat File2)
sed "s/var_hostname/${mValue}/" File1
1 Like
while read h
do
 sed '
   s/var_hostname/'"$h"'/g
  ' file1
done <file2