Crawl specific fields in the Log shell script

Source: Internet
Author: User

Boss let me put the information in the log summary, good trouble, wrote this script to help work.

Need to improve: 1. Crawl log time, only the last time, and this script will catch

2. Requires two time difference (e.g. 15:23:34 and 23:23:34), not completed

3.aix don't get used to it

#!/bin/ksh# Enter the destination file directory cd /user/lyb# Enter the identification field echo  start time     end time     customer group      number of customers  >> /user/file10#for i in  1 2 3 4  5 6 7 8 9 10 11 12 "while [ true ]doecho " please  input the filename "#变量名为文件名, Read -p does not make read filename  #取出需要的字段, when there are multiple identical fields in the file, Without judging the conditions s1= ' grep   ' received the registration Response message packet, start performing task resolution "  $filename   | sed  ' s/\. *//g ' s2= ' grep   "terminate the task processing finished, service exits"     $filename  | sed  ' s/\. *//g "s3= ' grep  " loads the customer group. * Users   $filename  | sed  ' s/^.*\[//g '  | sed  ' s /\].*$//g ' s4= ' grep   "loaded. * users"    $filename  | sed  ' s/^.*\[//g '  |  sed  ' s/\].*$//g ' #将取出的字段输入到文件echo      "$s 1"         " $s 2 "       " $s 3"         " $s 4 " >> /user/file10 done 

#计算时间差sql语句

#select Round ((to_date (' 2014-11-13 12:22:23 ', ' yyyy-mm-dd hh24:mi:ss ')-to_date (' 2014-11-13 12:12:32 ', ' yyyy-mm-dd Hh24:mi:ss ') *24*60) time from dual;


Crawl specific fields in the Log shell script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.