I would like to format my table in to html format using awk.
cat table.txt
COL1 COL2 COL4 COL5 COL3
BRCC hete 15869 105A 1
BRAC he 1799967 956G 1
BCAS he 7334543 369AFVC 2
RCA he 9534262 7806-14 4
RCA he 144848 1114A 5
RA he 206118 52A 5
BCAVV he 543304 3807TCD 5
BCA hoo 106091515 4308TDDSC 1
BCA hoo 206075 4563A 1
BCA hoo 799917 2612CDSA 1
BCA hoo 206076 513G 2
BCA hoom 16941 3113A 3
My awk solution:
awk 'BEGIN {print "<table>"} ; { print "<tr><td width="80">" $1 "</td><td width="80">" $2 "</td><td width="150">" $3 "</td><td width="150">" $4 "</td><td>" $5 "</td><tr>"} ; END { print "</table>"}' table.txt
I Have 2 Problems:
1. Problem:
I need to add {print "<table>"}
font style like:
awk 'BEGIN {print "<table style='font-size:8.0pt;font-family:"Verdana","sans-serif"'>"} ;
...
But there is a error with quoting:
awk: cmd. line:1: BEGIN {print "<table style=font-size:8.0pt
awk: cmd. line:1: ^ unterminated string
awk: cmd. line:1: BEGIN {print "<table style=font-size:8.0pt
awk: cmd. line:1: ^ syntax error
zsh: no such file or directory: font-family:Verdana,sans-serif>"} ; { print "<tr><td width="80">" $1 "</td><td width="80">" $2 "</td><td width="150">" $3 "</td><td width="150">" $4 "</td><td>" $5 "</td><tr>"} ; END { print "</table>"}
2. Problem:
And I would like to add "borders" to my table with "======" mark. So output look like:
COL1 COL2 COL4 COL5 COL3
===========================
col1 col2 col4 col5 col3
col1 col2 col4 col5 col3
col1 col2 col4 col5 col3
col1 col2 col4 col5 col3
===========================
A solution using
awk
to generate table inhtml
formatyou get in
table.html
,Because I see a
sed
tag, you may want to try this:Output::