Help in using html in Shell script

Hi,

I made a script that displays various fileds of report that are required in csv format and send it on mail(the csv file). Now I want to convert the csv format into html table and then send it on mail.

Reports_Output.csv

Code:

STREAM,INF,INREC,DUP_FILES,REJ_FILES,GAP,OLD,DISCARDED
mmsc,288,667901,183419,0,0,0,0
psoc,70,1059046,3176928,0,0,1,0
gsmo,192,573928,1727265,7131,0,0,0
roam,1807,257018,681672,35,0,1746,0

I want to display it in table format-(as example)

STREAMINFINRECmmsc288667901psoc701059046

I searched in the forum that could give me this kind of output but no luck.

Please help me.

Try:

awk '{print $1 $2 $3} END{print RS}' FS=, ORS=

What happened to lines 4 and 5 in your input file? Which condition rules them out? And - your sample doesn't really look a table. How about making up your mind on what you really need?

STREAM  INF   INREC    DUP_FILES
mmsc     288   667901   183419
psoc       70    1059046  3176928

It should display like this and so on with Table border.

You might want to peek into How to output the prstat into table and send through email? Post: 302938396

Thanks a lot. It worked.
I also want to format and fill colours in the table. Could you please help me.

try using the below sample script

$ cat outtohtml.sh
file=$1
`awk -F , ' BEGIN { print "<table border=1>"} \
NR == 1 { print "<th>";for(i=1;i<=NF;i++)print "<td><FONT COLOR=BLUE FACE="Geneva,Arial" SIZE=6>"$i"</FONT></td>";\
print "</th>" }\
NR > 1 {print "<tr>"; for(i=1;i<=NF;i++)print "<td><FONT COLOR=BLUE FACE="Geneva,Arial" SIZE=6>"$i"</FONT></td>";\
print "</tr>"} END { print "</table>" }' $file > $file.html`