Can anyone help me to send below data in html table format in mail body using shell script. sample file
abcd "this is to test" 123
csdf "another test" 10000
I have created below script but it breaks when there is space in the second column value
echo "send an email"
awk 'BEGIN {
print "<html><body><table border=1 cellspacing=0 cellpadding=3>"
print "<tr>"
print "<td>date</td>";
print "<td>name</td>";
print "<td>total</td>";
print "</tr>"
} {
print "<tr>"
print "<td>"$1"</td>";
print "<td>"$2"</td>";
print "<td>"$3"</td>";
print "</tr>"
} END {
print "</table></body></html>"
} ' sample.txt >> sample.html
(
echo "To: [email protected]"
echo "MIME-Version: 1.0"
echo "Subject:$v_subject"
echo "Content-Type: text/html"
cat sample.html
) | sendmail -t