【问题标题】:parsing aws cloudfront log解析 aws cloudfront 日志
【发布时间】:2012-12-28 04:17:48
【问题描述】:

我有一个解析 aws cloudfront 日志的 shell 脚本。

awk '{print $1","$2","$4","$5","$8","$9","(substr($11,1,7))","$12 }' access_log | grep cid= | sed -e 's/\/data//g;s/\/videos//g;s/\/images//g;s/\/hls//g;s/\/rss//g;s/\/xml//g;s/cid=//g' > stats.txt

我正在尝试组合字段 $1 和 $2,因此日期时间戳类似于以下格式: 约会时间 0000-00-00 00:00:00

目前在日期、时间两个字段中 2012-12-23 20:59:47

感谢任何帮助。

【问题讨论】:

    标签: parsing amazon-cloudfront logfiles


    【解决方案1】:

    脚本的 awk 部分在要格式化为日期时间的日期和时间部分之间添加逗号。这导致“YYYY-MM-DD HH:MM:SS”显示为“YYYY-MM-DD,HH:MM:SS”。

    要获得您在将脚本更改为后的结果:

    awk '{print $1" "$2","$4","$5","$8","$9","(substr($11,1,7))","$12 }' access_log | grep cid= | sed -e 's/\/data//g;s/\/videos//g;s/\/images//g;s/\/hls//g;s/\/rss//g;s/\/xml//g;s/cid=//g' > stats.txt
    

    这应该正确插入到日期时间字段中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-24
      • 1970-01-01
      • 2022-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-29
      相关资源
      最近更新 更多