file:
test 15:34:00
tes2 1:24:00ide
awk '{gsub(":"," ",$2);now=strftime("%Y %m %d",systime());print $1,mktime(now" "$2)}' code
gsub(":"," ",$2)將第二列用: 分割爲行ip
strftime("%Y %m %d",systime())獲取當前系統日期it
mktime(now" "$2) 將第二列和系統日期轉換爲時間戳class
[root@Demo1 scripts]# awk '{gsub(":"," ",$2);now=strftime("%Y %m %d",systime());print $1,mktime(now" "$2)}' test2
test 1515051240
tes2 1515000240test