在Unix上使用AWK/SED命令创建HTML表格

tpgth1q7  于 2022-09-21  发布在  Unix
关注(0)|答案(0)|浏览(132)

我有一份文件,看起来像这样。有没有办法将文件格式化为我想要的样子?(见下文)我使用了sed/awk的各种版本,但似乎不起作用。这样做的目的是为了在我的文件中获得更好的表,这样当我在Unix上使用mail命令发送它们时,它将通过读取html文本打印出一个表。非常感谢您对如何做到这一点的任何指示或直接帮助!

File
    Candy Max Capacity
    Skittle 2293 1.72
    M&m 3420 2.57
    choco 294 .22
    sugar  246 .18
    Salt Max Capacity
    one 2293 1.72
    two 3420 2.57
    three 294 .22
    four   246 .18
    Candy Max Capacity
    Skittle 2293 1.72
    M&m 3420 2.57
    choco 294 .22
    sugar  246 .18
    TONS OF WORDS AND INFO HERE. TONS OF WORDS AND INFO HERE. 
    TONS OF WORDS AND INFO HERE. TONS OF WORDS AND INFO HERE. 
    TONS OF WORDS AND INFO HERE. TONS OF WORDS AND INFO HERE. 
    TONS OF WORDS AND INFO HERE. TONS OF WORDS AND INFO HERE. 
    TONS OF WORDS AND INFO HERE. TONS OF WORDS AND INFO HERE. 
    TONS OF WORDS AND INFO HERE. TONS OF WORDS AND INFO HERE.

我希望它看起来像什么样子的例子。

MIME-Version: 1.0
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<table border="1" style="width:300px">
<tr>
<td>Candy</td><td>Update</td><td>Capacityt</td>
</tr>
<tr>
<td>SKittle</td><td>2293</td><td>1.72</td>
</tr>
<tr>
<td>M&M</td><td>3420</td><td>2.57</td>
</tr>
<tr>
<td>Choco</td><td></td> 294<td>.22</td>
</tr>
<tr>
<td>Sugar</td><td></td> 246<td>.18</td>
</tr>
</table>
</html>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题