此脚本过滤统计后台数据并显示为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