大家好,我是一个网络管理员,学习如何将人类可读的日期转换为一个时代,这样我就可以将它们导入到日志分析工具中,比如webalizer。
原创
Wed 11月17日17 :00 2021.014 1786 10.107.54.55 TCP_隧道/200 3964连接网站1.com:443- HIER_DIRECT/104.43.65.221
转换为
1637139600.014 1786 10.107.54.55 TCP_隧道/200 3964连接网站1.com:443- HIER_DIRECT/104.43.65.221
我有基本的UNIX知识,但不是很强。我试着跟踪这个帖子,How can I convert date in a column to a epoch timestamp in bash?,但没有成功。有人能帮我吗?
发布于 2021-11-19 01:40:52
嗨,我终于可以通过引用Convert date to epoch time using AWK in linux并使用cut命令-)来完成这个任务了。)
cut -b 2-400 log.txt | awk -F ']' '{ OFS = FS; command="date -d " "\"" $1 "\"" " +%s";command | getline $1; close(command); print $1 $2}'https://stackoverflow.com/questions/70017493
复制相似问题