shell使用/var/log/messages 信息生成HTML文件
脚本代码如下:
#!/bin/awk -f
BEGIN { # 定义每个颜色区域的开始字段及其颜色,以下表示的意思是 1-3 是red, 4-5是yellow, 6-末尾是blue ffmt = "1,4,6"; cfmt = "red,yellow,blue";
split(ffmt, field, ","); split(cfmt, color, ",");
print ""; print " message "; print ""; print ""; }
{ print "";
m = 1; for (i=1; i<=NF; i++) { if (i == field[m]) { if (i != field[1]) print ""; printf "[m] ">"; m++; } printf "%s ", $i; } print " | ";
print " "; }
END { print " "; print "
"; print ""; }
|
以上代码保存成 mess2htm.awk
chmod a+x mess2htm.awk
./mess2htm.awk message_file >message.html
阅读(660) | 评论(0) | 转发(0) |