[linux]写的一个服务器数据过滤HTML脚本

此脚本过滤统计后台数据并显示为HTML格式

# !/bin/sh

ls -l /home/work/tools/tomcat-splitter/data/ROOT/$1 | grep $2 |sort | awk '{print $9}' >tmp.txt
file1=`cat tmp.txt | sed -n '1p'`
grep $3 $file1 > $1$2$3.txt

file_input=$1$2$3'.txt'
file_output=$1$2$3".html"

td_str=''

function create_html_head(){
echo -e "<html>
<body>
<h1>$file_input</h1>"
}

function create_table_head(){
echo -e "<table border="1">"
}

function create_td(){
# if [ -e ./"$1" ]; then
echo $1
td_str=`echo $1 | awk 'BEGIN{FS=" "}''{i=1; while(i<=NF) {print "<td>"$i"</td>";i++}}'`
echo $td_str
# fi
}

function create_tr(){
create_td "$1"
echo -e "<tr>
$td_str
</tr>" >> $file_output
}

function create_table_end(){
echo -e "</table>"
}

function create_html_end(){
echo -e "</body></html>"
}


function create_html(){
rm -rf $file_output
touch $file_output

create_html_head >> $file_output
create_table_head >> $file_output

while read line
do
echo $line
create_tr "$line"
done < $file_input

create_table_end >> $file_output
create_html_end >> $file_output
}

create_html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值