Ferouz Nas
Ferouz Nas

Reputation: 5

how to use cat (text file) command with sed

i have the below file

cat index.txt

<table border="0">
<TR><TH>FULL DEPLOYMENT</TH></TR>
<TR bgcolor="#E2EBF8">
<TD>nv Name</TD>
<TD>Source Branch</TD>
TR bgcolor="#EEEEEE"></TD> <TD>master_SDP_BIL</TD> 
<TD>2018/02/18_16:37:14</TD> <TD></TD> <TD>testing</TD> 
<TD>[email protected]</TD>

in another file : cat findex.txt

cat findex.txt

<TD bgcolor=#00EE00>OK</TD> <TD bgcolor=#00EE00>OK</TD> <TD 
  bgcolor=#00EE00>OK</TD> <TD bgcolor=#00EE00>OK</TD>

i want to add the content of findex.txt to index.txt after

<TD>[email protected]</TD>

so final file will be:

<table border="0">
<TR><TH>FULL DEPLOYMENT</TH></TR>
<TR bgcolor="#E2EBF8">
<TD>Env Name</TD>
<TR bgcolor="#EEEEEE"></TD> <TD>master_SDP_BIL</TD> 
<TD>2018/02/18_16:37:14</TD> <TD></TD> <TD>testing</TD> 
<TD>[email protected]</TD> <TD bgcolor=#00EE00>OK</TD> <TD 
 bgcolor=#00EE00>OK</TD> <TD bgcolor=#00EE00>OK</TD> <TD 
 bgcolor=#00EE00>OK</TD> </TR>
 </table>

im using below command but it's adding index.txt instead of contect

sed -i 's/\@gmail.com</TD>\/"cat $(findex.txt)"/g' index.txt

Upvotes: 0

Views: 54

Answers (1)

Beta
Beta

Reputation: 99134

Use the 'read' command:

sed -i '/<TD>[email protected]<\/TD>/r findex.txt' index.txt

Upvotes: 1

Related Questions