如何邮寄表格格式脚本输出 [英] how to mail script output in table format
本文介绍了如何邮寄表格格式脚本输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有脚本的输出,像下面。
当前的结果:
文件名了destname行数bytesize
文件1默认1488 2248
文件2默认123 657
file3的默认123 456
file4将默认567 124
实际结果是像下面(如果可能的话有边框):
文件名了destname行数bytesize
文件1默认1488 2248
文件2默认123 657
file3的默认123 456
file4将默认567 124
我需要邮寄上述相同格式的内容。
解决方案
#!/斌/庆典输入=/路径/到/你/ file.txt的
TMPFILE =/路径/到/ tmpfile.html回声的Content-Type:text / html的;字符集=US-ASCII'> $ TMPFILE
awk的'BEGIN {打印< HTML><身体GT;<表边框= 1>中} {打印< TR>中;对于(i = 1; I< = NF;我++)打印< TD&GT ; $我< / TD>中;打印< / TR>中} END {打印< /表>< /身体GT;< / HTML>中}'$输入>> $ TMPFILE
邮件-s测试abc@xyz.com< $ TMPFILE
来源: http://www.unix.com/302556864-post5.html
I have the script output like below.
Current result:
Filename Destname rowcount bytesize
file1 default 1488 2248
file2 default 123 657
file3 default 123 456
file4 default 567 124
Actual result to be like below (if possible with borders):
Filename Destname rowcount bytesize
file1 default 1488 2248
file2 default 123 657
file3 default 123 456
file4 default 567 124
I need to mail above content in same format.
解决方案
#!/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" abc@xyz.com < "$tmpfile"
Source: http://www.unix.com/302556864-post5.html
这篇关于如何邮寄表格格式脚本输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文