file:
test 15:34:00
tes2 1:24:00
awk '{gsub(":"," ",$2);now=strftime("%Y %m %d",systime());print $1,mktime(now" "$2)}'
gsub(":"," ",$2)将第二列用: 分割为行
strftime("%Y %m %d",systime())获取当前系统日期
mktime(now" "$2) 将第二列和系统日期转换为时间戳
[root@Demo1 scripts]# awk '{gsub(":"," ",$2);now=strftime("%Y %m %d",systime());print $1,mktime(now" "$2)}' test2
test 1515051240
tes2 1515000240
转载于:https://blog.51cto.com/3635076/2057278