wangzhensheng - by - 27 四月, 2008 20:31

#!/bin/sh
log_file="$1"
date="$2"
begin_time="$3"
end_time="$4"
new_log="`hostname -i | awk -F[.] '{print $4}'`"

if [ $# -lt 4 ]; then
echo "`basename $0`: useing log_file(catalina.out) DATE(yyyy-m-d) begin_time(hh:mm) end_time(hh:mm) "
else
begin_grep="${date} ${begin_time}"
echo ${begin_grep}

end_grep="${date} ${end_time}"
echo ${end_grep}

begin_lines_num=`grep -n "${begin_grep}" ${log_file} | head -1 |awk -F'[:t]' '{print $1}'`
echo ${begin_lines_num}


end_lines_num=`grep -n "${end_grep}" ${log_file} | tail -1 |awk -F'[:t]' '{print $1}'`
echo ${end_lines_num}

lines=`expr ${begin_lines_num} - ${end_lines_num}`
echo ${lines}

head -${end_lines_num} ${log_file} | tail ${lines} >../logs/${new_log}_${begin_time}_${end_time}.log

fi


#!/bin/sh
log_file="$1"
date="$2"
begin_time="$3"
end_time="$4"
new_log="`hostname -i | awk -F[.] '{print $4}'`"

if [ $# -lt 4 ]; then
echo "`basename $0`: useing log_file(catalina.out) DATE(yyyy-m-d) begin_time(hh:mm) end_time(hh:mm) "
else
begin_grep="${date} ${begin_time}"
echo ${begin_grep}

end_grep="${date} ${end_time}"
echo ${end_grep}

begin_lines_num=`grep -n "${begin_grep}" ${log_file} | head -1 |awk -F'[:t]' '{print $1}'`
echo ${begin_lines_num}


end_lines_num=`grep -n "${end_grep}" ${log_file} | tail -1 |awk -F'[:t]' '{print $1}'`
echo ${end_lines_num}

lines=`expr ${begin_lines_num} - ${end_lines_num}`
echo ${lines}

head -${end_lines_num} ${log_file} | tail ${lines} >../logs/${new_log}_${begin_time}_${end_time}.log

fi


    最新回复

博客日历
« 八月 2008 »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
搜索
管理控制台
TOP_Read
TOP_Reply
New_Reply
文章分类
网站链接
新闻聚合
RSS 0.90
RSS 1.0
RSS 2.0
Atom 0.3