0

I have a hive query result in tab separated format. I am storing it into a file like

query="select Name, age from table;"
echo $query | hive > test.csv

Now I want to send it in mail using mutt command in tabular format. I am using command:

mutt -e -n "set Content-Type:text/html" -s"This is my mail" <test.csv

It shows result in mail body as tab separated format I want to make it in tabular format.

query result is in test file like this. and this is appear in mail body

NAME    ssingh
AGE    20

Currently It is separated by Tab and I want to convert it in html table format in mail body

Now I am able to generate data in excel 2003 format. Can we convert the excel data into HTML table and send it in mail body using mutt.

  • 2
    For those of us who don't know hive, can you show us the format of the test file (i.e. show us some of the content). – EightBitTony Jul 17 '13 at 8:15
  • in addition to what EightBitTony mentioned. It seems want to send the mail in html, when you say tabular do you mean convert the file to html table? Or do you mean list of values separated by tabs? – BitsOfNix Jul 17 '13 at 8:48
  • Yes I wan to convert the file data into HTML table – Sandeep Singh Jul 17 '13 at 9:44
  • Is there any option to convert excel data into html table in mail body ?? – Sandeep Singh Jul 17 '13 at 11:31
0

So finally I did it:

First I converted tab separated file into , separated file. Here is command

sed -i 's/\t/,/g' $filepath/test.csv

Now converted , separated file into test.html file. Here is code link:

http://www.unix.com/unix-dummies-questions-answers/118855-convert-csv-html-file.html

Then

mutt -e -n "set Content-Type:text/html" -s"This is my mail" < test.html

This will print file content in html tabular format in mail body

0

I know it's a late answer to this question, but will help those googling for a solution, for converting bash command output to html table format. There is an easy script available to do this at : https://sourceforge.net/projects/command-output-to-html-table/ which can be used to convert any command output or file to a nice html table format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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