LoginSignup
0
0

More than 5 years have passed since last update.

HTTPのアクセスログをgawkを使ってsortする

Posted at

参考 http://gihyo.jp/magazine/SD/archive/2015/201505

出力はCSVファイル、セパレータは@になってます。

##===事前処理
BEGIN {
    FPAT="([^ ]+)|(\"[^\"]+\")|(\[[^\[]+[^\]]+\])"
}

##===本体処理

{
    freq_of[$1"@"$9]+=1
}

##===事後処理
END {
    OFS="@"
    for ( i in freq_of ) {
        if ( ! freq_of[i] ) {
            freq_of[i] = 0
        }
        print i, freq_of[i]
        total+=freq_of[i]
    }
    print "total " total
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0