LoginSignup
2
0

More than 5 years have passed since last update.

ちょいメモ(個人メモ)

Posted at

DBロードまではPythonを使わないほうが良いような予感がしてきた。
awk/sed/grepで対応したい。

項目抽出はこんな感じで狙い撃ちができる

cat access.log | sed -E 's/^(.*) .* .* \[(.*)\] ".* (.*) .*" (.*) (.*) "(.*)" "(.*)"$/\1\t\2\t\3\t\4\t\5\t\6\t\7/g'

時間部分の編集をどうするかが課題。
時間編集はこれで行けそう

cat access.log | sed -E 's/^(.*) .* .* \[(.*)\] ".* (.*) .*" (.*) (.*) "(.*)" "(.*)"$/\2/g'
↓
25/Jan/2018:13:22:24 +0900
awk '{print $1}' | awk -F':' '{print $1"/"$2":"$3":"$4}' | sed -e 's/Jan/01/g' | awk -F"/" '{print $3"/"$2"/"$1" "$4}'
↓
2018/01/25 17:38:01

とも思ったが特定の列のみにawk/sedを適用するとなると
コードを書かねばならぬ模様。であれば結局最初からPython使ってもいいんでは。。。の予感がしている。

2
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
2
0