微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux-如何以表格格式邮寄脚本输出

我有如下的脚本输出.

当前结果:

Filename Destname rowcount bytesize
file1 default 1488 2248
file2 default 123 657
file3 default 123 456
file4 default 567 124

实际结果如下所示(如果可能,带有边框):

Filename  Destname  rowcount  bytesize
file1     default   1488      2248
file2     default   123       657
file3     default   123       456
file4     default   567       124

我需要以相同格式邮寄上述内容.

解决方法:

#!/bin/bash

input="/path/to/your/file.txt"
tmpfile="/path/to/tmpfile.html"

echo 'Content-Type: text/html; charset="us-ascii" ' > "$tmpfile"
awk 'BEGIN{print "<html><body><table border=1>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table></body></html>"}' "$input" >> "$tmpfile"
mail -s "test" [email protected] < "$tmpfile"

来源:http://www.unix.com/302556864-post5.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐