Home > Mobile >  Awk command gets a syntax error when creating an HTML
Awk command gets a syntax error when creating an HTML

Time:01-02

Trying to create a script that creates HTML from a TXT (which is converted from a coma separated CSV) but i get the syntax error on the first print "\ the mark shows " but i cant find the reason why any clues?

awk 'BEGIN {
 FS=","
 print "<style>\
    .my_table {font-size:8.0pt; font-family:\"Verdana\",\"sans-serif\"; border-bottom:3px double black; border-collapse: collapse;
}\n\
     .my_table tr.header{border-bottom:3px double black;}\n\
     .my_table th {text-align: left;}\
 </style>"
 print "<table class=\"my_table\">"
}
NR == 1{
 print "<tr class=\"header\">"
 tag = "th"
}
NR != 1{
 print "<tr>"
 tag = "td"
}
{
 for(i=1; i<=NF;   i) print "<" tag " width=\"" widths[i] "\">" $i "</" tag ">"
 print "</tr>"
}
END { print "</table>"}' dataset.txt > document.html

CodePudding user response:

You missed quoting EOL or mistyped newline here: collapse;}

  • Related