Czzawk
Upcoming SlideShare
Loading in...5
×
 

Czzawk

on

  • 1,640 views

 

Statistics

Views

Total Views
1,640
Views on SlideShare
833
Embed Views
807

Actions

Likes
1
Downloads
13
Comments
0

8 Embeds 807

http://chenzongzhi.info 744
http://175.41.172.193 40
http://50.18.120.192 13
http://www.chenzongzhi.info 6
http://www.sporcle.com 1
http://chenzongzhi.info} {1846359649|||pingback 1
http://cache.baidu.com 1
http://baotiao.github.io 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Czzawk Czzawk Presentation Transcript

  • awk
  • awk• · Peter Weinberger Brian Kernighan•
  • awk• sed , awk .
  • awk••••
  • • lastchenggan pts/467 192.168.130.29 Thu Aug 18 15:39 still logged inchenggan pts/446 192.168.130.29 Thu Aug 18 15:38 still logged inchenggan pts/414 192.168.130.29 Thu Aug 18 15:33 still logged inchenggan pts/414 192.168.130.29 Thu Aug 18 15:26 - 15:32 (00:06)lixinhe pts/413 192.168.130.34 Thu Aug 18 15:25 still logged inlixinhe pts/521 192.168.130.34 Thu Aug 18 15:09 still logged inxuzhang pts/509 192.168.129.2 Thu Aug 18 15:03 still logged in
  • • ip
  • • last | awk ‘{printf $1, $3}’ chenggan 192.168.130.29 chenggan 192.168.130.29 chenggan 192.168.130.29 chenggan 192.168.130.29 lixinhe 192.168.130.34 lixinhe 192.168.130.34 xuzhang 192.168.129.2
  • awk• , $0,$1,$2... .• Pattern { Actions } Action• { Actions }• ,
  • chenggan pts/467 192.168.130.29 Thu Aug 18 15:39 still logged in$0 = chenggan pts/467 192.168.130.29 Thu Aug 18 15:39 still logged in$1 = chenggan$2 = pts/467$3 = 192.168.130.29$4 = Thu$5 = Aug Pattern . Action print $1, $3 $1 $3
  • awk• FILENAME• FS ,• NF ,• OFS• FNR
  • • cat /etc/passwdbeanstalkd:x:107:110:beanstalkd user:/var/lib/beanstalkd:/bin/falsepostfix:x:89:89::/var/spool/postfix:/sbin/nologinprivoxy:x:73:73::/etc/privoxy:/sbin/nologin_tor:x:108:514:Tor user:/var/lib/tor:/bin/falsemurongjun:x:518:501::/home/murongjun:/bin/bashliying:x:519:501::/home/liying:/bin/bash
  • •• ?
  • • cat /etc/passwd | awk { FS=":"; print $1, $6;} beanstalkd /var/lib/beanstalkd postfix /var/spool/postfix privoxy /etc/privoxy _tor /var/lib/tor murongjun /home/murongjun liying /home/liying
  • • cat /etc/passwd | awk { FS=":"; OFS = " || "; print $1, $6;} beanstalkd || /var/lib/beanstalkd postfix || /var/spool/postfix privoxy || /etc/privoxy _tor || /var/lib/tor murongjun || /home/murongjun liying || /home/liying
  • • , , id, , . cityid.• php , sql .• php 20 ,awk 1
  • 107255,"2011-06-17"," ",15201095922,0663805,"2011-07-18"," ",13521050527,0346569,"2011-05-31"," ",84920575,84920575268831,"2011-05-29"," ",13601180538,0551017,"2011-04-20"," ",84920575,84855168
  • • awk -F "," { printf "insert into dealrevisit values (%s,%s,%s,10,0,UNIX_TIMESTAMP());n", $1, $3, $4;} beijing > insert.sql
  • insert into dealrevisit value (967898," ",13681190863,10,0,UNIX_TIMESTAMP());insert into dealrevisit value (582907," ",13901316805,10,0,UNIX_TIMESTAMP());insert into dealrevisit value (734974," ",15010372631,10,0,UNIX_TIMESTAMP());insert into dealrevisit value (868768," ",18600011579,10,0,UNIX_TIMESTAMP());
  • • FS ,FS , .• FS AWK
  • Pattern { Action }• Pattern { Action } AWK .• Pattern, Action
  • Pattern { Action }• AWK Pattern• awk ‘BEGIN{Action}; Pattern{Action};Pattern {Action};...; END{Action}’ file
  • BEGIN AND END• BEGIN AND Pattern• BEGIN• END
  • ......create mode 100644 mis/template/mobileads/list.php create mode 100644 model/MobileadsModel.php create mode 100644 model/TpBankBranchModel.php create mode 100644 model/TpBankInfoModel.php create mode 100644 model/TpPaymentLogModel.php create mode 100644 sql/110818_moddeallog.sql<em:version>0.1.3</em:version>......
  • • 0.1.3
  • • <em:version>...
  • • awk $0 ~ /<em:version>[^<]*</em:version>/ {print $0;} install.rdf |awk -F > {print $2}|awk -F < {print $1}
  • • $0 ~ /<em:version>[^<]*</em:version>/ Pattern.• $0 , / <em:version>[^<]*</em:version>/• {print $0;} Action
  • • awk <em:version>0.1.3</ em:version>• awk > 0.1.3</ em:version• awk < 0.1.3
  • Pattern { Action }• AWK
  • 202.106.58.18 - - [15/Aug/2011:23:59:42 +0800] 735802 -"GET /acl/account/checkurl?url=/mis/deals/default/all/jining&citySlug=jilin HTTP/1.0" 302 - "http://www.meituan.com/mis/" ....221.223.96.234 - - [15/Aug/2011:23:59:58 +0800] 450858 -"GET /deal/1105.html HTTP/1.0" 200 2132 "http://www.meituan.com/mis/account/login"
  • • apache• url , url url• url mis• grep , grep
  • • awk $9 ~ /mis/ { print $0} log
  • • awk awk B
  • Pattern { Action }• AWK Pattern >,<• awk $1 + $2 < 100 test 100 Pattern Action, Action• AWK Pattern !~ .
  • awk• awk shell , awk
  • 3199, , ,187****9445, BD ( )3228, , ,136****9587, BD ( )2962, , ,136****7116, BD ( )2963, , ,137****0897, BD ( )5554, , ,186****2154,4838, , ,134****7617, BD ( )4882, , ,139****5562, BD ( )
  • • .
  • • php , 20 ,awk 1
  • • awk BEGIN {FS=","} { print $0 >>$2; close($2);} cityuser
  • • , . $2 .• close• awk close()
  • awk• getline .• getline , .• ,getline 1, 0, , , -1.
  • • awk BEGIN { while("who" | getline) n++; print n;}• .
  • • awk BEGIN {"date" | getline dtime; print dtime}•• data dtime,
  • 202.106.58.18 - - [17/Aug/2011:23:59:51 +0800] 1042839 - "GET /mis/deals/default/all/ningbo HTTP/1.0" 200 17505 "http://www.meituan.com/mis/frame/side?city=ningbo" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0""uuid=13ce7442b68505d69df7.1297390972.68.4.1; __utma=1.64891309.1297390974.1313584928.1313594207.499;__utmz=1.1313594207.499.164.utmcsr=%28none%29|utmccn=UserReferral|utmcmd=im|utmctr=index|utmcct=u313552;mb=15210890172; ci=135; __utmv=1.|1=city=yuncheng=1,2=user=BD=1; abt=1313544681%7CADF; m=chuan_ye_lony%40163.com; al=HRPAxN_gimR2EVusR69-AhDTM2t0V-Z7ENMza3RX5nvXmpHDt8V-XQ;SID=vp8csbhtgc1g42f3villuod0g7; u=2506429; n=%E7%82%B9%E7%82%B9%E5%B0%8F%E9%9B%A8%E5%B0%98; __utmc=1;au=2367; MisCitySlug=ningbo; em=Tjs; rf=1313584922-4752116b-313552; __utmb=1.87.9.1313594355400; om=Tjs"www.meituan.com
  • • apache , mis , au, cookie acluserid . au url.
  • • , , au id url• ,
  • • cat www.meituan.com-110810-access_log | grep /mis | grep au= | awk { FS="""; printf("%sau=%sn"),$2, $0;} | awk {FS="au="; printf("%s %sn"), $1,$3;}| awk {FS="[;”]"; print $1} | awk {print $2,$1} |awk {FS="?"; print $1}| awk {FS="/"; for(i=1;i<=NF;i++) {printf("%s/"),$i; if (i==4) {break;}};printf("n");} | sed "s_//_/_g" > gui
  • • awk ” GET /mis/ deals/default/all/ningbo HTTP/1.0au=• awk ”au=” GET / mis/deals/default/all/ningbo HTTP/1.0 2367; MisCitySlug=ningbo; em=Tjs;
  • • [;”] GET /mis/ deals/default/all/ningbo HTTP/1.0 2367•
  • ,3349,,1422,/mis/frame/toggle/ || /mis/frame/side/ || /mtm/ || /mtm/index/list/ || /mis/deals/default/ || /acl/account/checkurl/ || /mis/deal/edit/ ,2435,,974,/mis/frame/toggle/ || /mis/frame/side/|| /mtm/ || /mtm/index/list/ || /acl/account/checkurl/ || /mtm/index/ || /mis/deals/default/
  • grep in awk• , 50 , id ip, .• gui id apache log .
  • grep in awk• awk grep , grep . $0 grep
  • grep in awk• awk BEGIN { while (( getline < "/var/ sankuai/wwwlogs/ www.meituan.com-110816-access_log" > 0))  { f2[lc] = $0; lc++;}} -F "," { name = "au="$2"[;|"]"; for (i = 1; i < lc; i++) {if (f2[i] ~ name) print f2[i];} printf("nn");} zhuagui.ouput > zhuagui50
  • grep in awk• getline log f2 . BEGIN Pattern .• gui f2 .• name name =
  • • , awk ,
  • ^-^