shell 脚步分析数据
来源:互联网 发布:js toggleclass 编辑:程序博客网 时间:2024/05/19 11:44
开始尝试用shell 脚步分析软件输出数据
#!/bin/sh:<<!input file n : difference device file compare e : same device file compare!device=$1 log_file_a=$2log_file_b=$3#convert file dos2unix $log_file_ados2unix $log_file_b#judge file if [ n == $device ] || [ e == $device ];thenif [ ! -f "$log_file_a" ];thenecho -e "no input compare file param1!\c";exit 2elseif [ ! -f "$log_file_b" ];thenecho -e "no input compare file param2!\c";exit 2fifielseecho -e "shell Usage error ! \c";exit 2fi#record last find success linelast_condition=0#multiple start time must record linemulti_line=0line=1;last_line=0;last_line_tmp=0count_num=0condition=0if [ e == $device ]thenOAR_Line=$(awk '{print NR}' $log_file_b | tail -1)cat $log_file_a | while read GAS_timedolet count_num++if (( $count_num%100 == 0 ));thenecho " handle alarm $count_num"fiGAS_time=$(echo ${GAS_time##*G:})GAS_time_s=$[GAS_time+1]#echo $GAS_timestime=0;etime=0;GAS_time_e=0if [ 1 == condition ];thenline='expr $line - 1'if [ 0 -ne multi_line ];thenline='expr $last_line - $multi_line'multi_line=0fielseline=1ficondition=0while [ $line -le $OAR_Line ]doif [ 1 == line ]thenstime=$(awk 'NR=='$line' {print $0}' $log_file_b)#stime=$(sed -n ''$line'p' $log_file_b)elsewhile [ $line -ge 3 ]dostime=$(sed -n ''$line'p' $log_file_b)if [[ "$stime" =~ "S=" ]]thenlet last_line_tmp=line-1etime_tmp=$(sed -n ''$last_line_tmp'p' $log_file_b)if [[ "$etime_tmp" =~ "E=" ]]thenbreakelselet line--continuefielselet line--continuefidonefistime=$(echo ${stime##*S=})[ ! $stime = ~^[0-9] ] || echo -e "GAS_time:$GAS_time GAS_time_s:$GAS_time_s stime:$stime \c"let line++etime=$(sed -n ''$line'p' $log_file_b)while [ $line -le $OAR_Line ];doif [[ "$etime" =~ "E=" ]]then#echo $etimebreakelselet multi_line++let line++etime=$(sed -n ''$line'p' $log_file_b)fidoneetime=$(echo ${etime##*E=})#GAS_time=$[GAS_time+1]let GAS_time_e=GAS_time+8#echo "GAS_time_e:$GAS_time_e stime:$stime etime:$etime "#if [ 1488870848 = $GAS_time ];then#echo "GAS_time:$GAS_time GAS_time_s:$GAS_time_s GAS_time_e:$GAS_time_e stime:$stime etime:$etime "#fi[ ! $etime = ~^[0-9] ] || echo -e "GAS_time:$GAS_time GAS_time_s:$GAS_time_s GAS_time_e:$GAS_time_e stime:$stime etime:$etime \c"if [ $GAS_time_s -ge $stime ];thenif [ $GAS_time_e -lt $etime ];thencondition=1last_line=$linebreakfifilet line++doneif [ 0 -eq $condition ];thenecho -e " *** error ***: \c";echo "GAS_time:$GAS_time GAS_time_e:$GAS_time_e stime:$stime etime:$etime "fidoneelif [ n == $device ]thenline_num_b=$(awk '{print NR}' $log_file_b | tail -1)cat $log_file_a | while read time_adobequal=0;line_b=1old_time_a=$time_anew_time_a=$(echo ${time_a##*G:})while [ $line_b -le $line_num_b ];dotime_b=$(sed -n ''$line_b'p' $log_file_b)time_b=$(echo ${time_b##*G:})if [ $new_time_a -eq $time_b ];thenbequal=1break;filine_b=`expr $line_b + 1`doneif [ 0 -eq $bequal ];thenecho " error in another file no find : $old_time_a"fidoneelseecho -e "shell fisrt praram error ! \c";exit 2fi
备注
0 0
- shell 脚步分析数据
- shell 脚步
- [linux]shell脚步记录
- 一些常用shell脚步
- CMake调用shell脚步
- 清理缓存的shell脚步
- linux C 执行shell脚步
- shell 获取脚步名称方法
- Shell 自解压安装脚步
- 使用 shell 脚步循环执行命令
- shell脚步错误“command not found 2:”
- shell 脚步批量转换文件编码
- shell 脚步获取当前的函数名
- Shell脚步中的递归函数以及遍历目录
- 检查tar版本的shell脚步checktar.sh
- shell笔记-使用awk数据分析
- 数据共享与数据安全(学习脚步)
- 从数据库查找关键数据创建话单的脚步
- redis部署
- android组件ListView之BaseAdapter简单使用
- html5调控颜色
- 【代码重构 & JDT】修改Eclipse重构撤回的深度限制
- AngularJS的组件化、过滤器、自定义过滤器之旅
- shell 脚步分析数据
- RemoteViews的解析
- servlet在web应用中的过程
- 关于javascript对象的认识详解
- dblink创建以及出现问题
- B
- Ubuntu16.10安装Lua5.3.4
- 安卓逆向工程与代码安全
- js基础运算符