1 Star 0 Fork 3

zhangchi/logcover

forked from 百度开源/logcover 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
merge_log.sh 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
考拉睡 提交于 2013-11-29 14:35 . add logcover sourcecode
#/sbin/sh
#--------------param check------------------------------------#
#if [[ $# -ne 2 ]] || [[ ! -d $1 ]] ||[[ `expr match $2 ".*/$"` -gt 0 ]];then
src_filter_log_path=$1
dst_log=$2
if [[ $# -ne 2 ]] || [[ ! -d $1 ]] ||[[ "${dst_log:(-1)}"x = "/"x ]];then
echo "param is error,use:"
echo "sh merge_log.sh filter_log_directory resut_file"
exit -1
fi
#dir complete
#if [[ `expr match ${src_filter_log_path} ".*/"` -eq 0 ]];then
# src_filter_log_path="${src_filter_log_path}/"
#fi
#clean dst_log_file
if [[ -e ${dst_log} ]];then rm ${dst_log} ;fi
#if only one file
#if [[ `ls ${src_filter_log_path} |wc -l` -eq 1 ]];then
# cp ${src_filter_log_path}/`ls ${src_filter_log_path}` ${dst_log}
# exit
#fi
tmp_merge_log="_tmp_merge_log"
tmp_merge_log_uniq="_tmp_merge_log.uniq"
#get all the log key word from the result of filter_log.sh and then sort
egrep -roh ".*\.[A-Za-z0-9_\-]+%%[0-9]+L?%%" ${src_filter_log_path}/ > ${tmp_merge_log}
sort ${tmp_merge_log} |uniq > ${tmp_merge_log_uniq}
#get the log by tmp file
while read -r line;do
one_log=`fgrep -rh "${line}" ${src_filter_log_path}/ |head -n 1`
if [[ ! -z ${one_log} ]]; then
echo "${one_log}" >> ${dst_log}
fi
done < ${tmp_merge_log_uniq}
rm ${tmp_merge_log}
rm ${tmp_merge_log_uniq}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zczc8/logcover.git
git@gitee.com:zczc8/logcover.git
zczc8
logcover
logcover
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385