我有很多次来自 apache 日志...
96.99.193.124 - - [10/May/2012:22:59:29 +0000] 0 "GET / " 200 123 "-" "-"
96.29.193.124 - - [10/May/2012:22:59:56 +0000] 0 "GET / " 200 123 "-" "-"
96.29.193.125 - - [10/May/2012:22:59:56 +0000] 0 "GET / " 200 123 "-" "-"
96.29.193.125 - - [10/May/2012:23:00:00 +0000] 0 "GET / " 200 123 "-" "-"
96.29.193.125 - - [10/May/2012:23:00:00 +0000] 0 "GET / " 200 123 "-" "-"
要提取日期时间戳,我会:
sed -e 's;^.*\(\[.*\]\).*$;\1;' inputFileName > outputFileName
这给了我
[10/May/2012:22:59:29 +0000]
[10/May/2012:22:59:56 +0000]
[10/May/2012:22:59:56 +0000]
[10/May/2012:22:59:56 +0000]
[10/May/2012:23:00:00 +0000]
[10/May/2012:23:00:00 +0000]
我想删除秒部分、方括号和秒,然后得到:
10/May/2012:22:59
10/May/2012:22:59
10/May/2012:22:59
10/May/2012:23:00
10/May/2012:23:00
从原始文件中......有什么提示吗?