↓こーいう ログがあったりする test.log
↑これの uidとshop_idを取り出す
# アクセスログとかから、欲しいパラメータだけ取り出すスクリプト # # usage: awk -f get_log_param.awk [log file path...] { # shop_id shop_id = match($0, /shop_id=[0-9]+/) if (shop_id != 0) { shop_id = substr($0, shop_id+8, RLENGTH-8) } # uid uid = match($0, /uid=[0-9]+/) if (uid != 0) { uid = substr($0, uid+4, RLENGTH-4) } if (shop_id != 0) { printf "shop_id=%d | ", shop_id } if (uid != 0) { printf "uid=%d", uid } print "" }
実行
shop_id=204066 | uid=10009158shop_id=197514 | uid=10018366shop_id=205051 | uid=10010135shop_id=218547 | uid=10003620shop_id=220207 | uid=10001037shop_id=203185 | uid=10103004
参考)
Awkプログラミング入門-第5回
0 件のコメント:
コメントを投稿