Emplyoyee Information:

Name    Age   DOB
______  ___   _________
Jones   54    06/12/1998 
Allen   50    06/09/1990

I want to see the above output in a table.

  • You can send a HTML email with a table. Otherwise, the result depends on the font the recipient uses to display the email. – RalfFriedl Aug 12 '18 at 12:06
  • 2
    How is Jones 54 years old if he was born in 1998? – Jesse_b Aug 12 '18 at 12:18
  • 2
    please try to ask a clear question. 1- what do you need, 2- what are your input , 3- what are your expected – Hossein Vatani Aug 12 '18 at 12:33

Using html as RalfFriedl suggested:


In order to send an HTML email using something like sendmail you need to have an html email header. For this I use a temp file to store the contents like this:

mailsub='This is the subject of my email'
curdate=$(date "+%a, %d %b %Y %H:%M:%S %z")
html_header="From: <${mailfrom}>\nTo: <${mailto}>\nSubject: ${mailsub}\nDate: <${curdate}>\nContent-Type: text/html; charset=utf-8\n"
echo -e "$html_header" > tmp_file

This will create a header like:

From: <from@address.com>
To: <to@address.com>
Subject: This is the subject of my email
Date: <Sun, 12 Aug 2018 12:30:17 +0000>
Content-Type: text/html; charset=utf-8

You can then add your table to the file and cat tmp_file | mail -t


1) As ascii:

    printf "%-10.10s %3.3s %12.12s\n" $1 $2 $3

prtline Name Age DOB
prtline _______ __________ ___________
prtline Jones 54 06/12/1998
prtline  Allen 50 06/09/1990

2) As html-table:

echo "<table>"
echo "<tr><td>Name</td><td>Age</td><td>DOB</td></tr>"
echo "<tr><td>Jones</td><td>22</td><td>1821</td></tr>"
echo "</table>"

3) with tbl/groff/ps2pdf. This will give you predictable nice results, but may be a bit more complicated. You would have to send the pdf as an attachment.


Use the below code to convert the CSV file into HTML:

Install nawk to use this code

nawk 'BEGIN{
print  "<p>Hi,<br/><br/>"
print  "Please find the Employee details.<p>"
print  "<HTML>""<TABLE border="1"><TH>Name</TH><TH>Age</TH><TH>DoB</TH>" 
printf "<TR>"
printf "<TD>%s</TD>", $i
print "</TR>"
print "</TABLE>"
print "<p><br/>Thank You,<br/>"
print "Team HR<p>"
print "</BODY></HTML>"
' employeedetails.csv > employeeDetails.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.