tformat.py
#!/bin/python
import time
import sys
data = sys.stdin.readlines()
for line in data:
seconds = int(line.split(':')[0])
s_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(seconds))
print s_time,line.split(':')[1].rstrip()
使用方法:
chmod a+x ./tformat.py cat file | ./tformat.py
另一种用法: 1646481238: Client 357734500178325 has exceeded timeout, disconnecting.
leon@ubuntu:~/work$ cat <
1646481238: Socket error on client 357734500178325, disconnecting.
1646481545: New client connected from 223.73.212.49 as 357734500178325 (c1, k600).
EOF
2022-03-05 11:53:58 Client 357734500178325 has exceeded timeout, disconnecting.
2022-03-05 11:53:58 Socket error on client 357734500178325, disconnecting.
2022-03-05 11:59:05 New client connected from 223.73.212.49 as 357734500178325 (c1, k600).



