shell 实现txt转换成html
2015-02-09 14:56
387 查看
shell源码
[python] view
plaincopyprint?
[python] view
plaincopyprint?
# !/bin/sh
file_input='txt.log'
file_output='txt2html.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
[python] view
plaincopyprint?
[python] view
plaincopyprint?
# !/bin/sh
file_input='txt.log'
file_output='txt2html.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
相关文章推荐
- shell 实现txt转换成html
- shell 实现txt转换成html
- shell 实现txt转换成html
- shell 实现txt转换成html
- shell 实现txt转换成html
- shell 实现txt转换成html
- shell命令实现txt文件转换为csv文件
- Flash ActionScript3.0 中txt文档根据模板转换成html文档的实现
- shell实现txt转为html
- linux shell txt转换成html的实现代码
- shell实现txt转换excel
- linux shell txt转换成html的实现代码
- 转换HTML为TXT
- asp下实现对HTML代码进行转换的函数
- Delphi 和Foxpro整合实现txt和dbf互相转换
- Html 转换 Txt
- Adobe向苹果让步:发布新工具实现转换HTML5
- php将HTML转换为txt文本的函数
- C#实现EXCEL数据转换到TXT文档
- 一个在HTML使用JavaScript实现调用Windows Shell.Application的例子。