Shell's log processing

Source: Internet
Author: User
Tags egrep

#!/bin/bash#by lc at 20160428 for hadoop (grep_recharge) DATE= ' Date +%F_%H\:%M\:%S ' ytdate= ' date -d  " -1 day"  +%y%m%d ' restdir=/home/hadoop/prodata/restdatedir=/home/hadoop/ prodata/rest/$YTDATERESTFILE =${datedir}/recharge-$YTDATE. log#restfile=recharge-20160427.log#newfile= parse-recharge.lognewfile=${datedir}/parse-recharge-$YTDATE. Loglogfile=/server/scripts/grep_ Recharge.logfunction checkfile () {>  $NEWFILEWCRESTFILE = ' wc -l  $RESTFILE ' echo  ' ##### ################### '  >>  $LOGFILEecho   "${date} go ..."  >>  $LOGFILEecho   "$WCRESTFILE"  >>  $LOGFILEif  [ ! -e  $RESTFILE  ]  then      echo  "$RESTFILE  cant find"  >> $LOGFIL      exit 1fi}function grepfile () {egrep -v  "Rechmoney|money_order"  ${RESTFILE}|grep  -v  ' cardnum '  |awk -f '[{] '   ' {print $1} ' |sed -nr  ' s# (. *) #\1\{\} #gp " >${newfile}###### #CardNumegrep  - v  "Rechmoney|money_order"  ${RESTFILE}|grep  ' Cardnum ' |grep  "[0-9]\{8\}\" \}$ "|sed -nr   ' s# (. *) \{.*\}#\1\{\} #gp '  >>${NEWFILE}egrep -v  "Rechmoney|money_order"  ${ restfile}|grep  ' Cardnum ' |grep -v  "[0-9]\{8\}\" \}$ "|tr  ' {} '   ' 1 ' |sed -nr  ' s# ( . *) #\1\|\{\} #gp '  >>${newfile}##### #Money_Ordergrep   "Money_order"  ${RESTFILE}|sed  ' s# \\# #g ' |tr  ' {'   ' # ' |sed -nr  ' s# (. *) \#.*\#.*money_order (. *) #\1\{\ "RECHMONEY\2#GP ' |sed  ' s #\## #g ' |sed  ' s#iphone[0-9],[0-9] #iPhone #g ' |sed  ' s#ipod[0-9],[0-9] #iPod #g ' |sed  ' s#ipad[0-9],[0-9 ] #iPad #g ' |awk -f[,]  ' {print $1 "\,\" recharge\ "\:\" param\ "\}"} ' |sed  ' s#\ ' data\ ': # #g '   >>${newfile}###### #rechMoneygrep   "Rechmoney"  ${RESTFILE}|sed  ' s#\\# #g ' |tr  ' {'   ' # ' |sed -nr " s# (. *) \#.*rechmoney (. *) #\1\ "RECHMONEY\2#GP" |sed  ' s#\## #g ' |sed  ' s#iphone[0-9],[0-9] #iPhone #g ' |sed   ' s#ipod[0-9],[0-9] #iPod #g ' |sed  ' s#ipad[0-9],[0-9] #iPad #g ' |awk -f ' [,] '   ' {print $1} ' | sed  ' s#\}# #g ' |awk -f ' ["] '   ' {print $1" \{\ "" $ "\" "$ $" \ "$4" \ "\,\" recharge\ "\:\" param\ "\}"} '  >>${NEWFILE}echo  "' Wc -l ${newfile} '  "  >>  $LOGFILEif  [  $? -ne 0 ]  then     echo  "' date +%f_%h\:%m\ :%s '   not ok '  >>  $LOGFILE   else     echo   "' date +%f_%h\:%m\:%s '  ok"  >> $LOGFILEfi}main  () {  checkfile   grepfile}main


This article is from the "10886311" blog, please be sure to keep this source http://10896311.blog.51cto.com/10886311/1836643

Shell's log processing

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.