需求:
排查线上问题,回溯历史数据,需要知道历史数据执行到什么时间(日志有时间戳数据), 但是时间戳不易读。因此使用 xargs 做转换
实现:
for i in `seq -w 50 69`; do echo " log time ,1560${i}2917,xxx"; done |awk -F ',' '{print "@"$2}' |xargs -I{} date --date {} ; date +"%F"
输入:
log time ,1560502917,xxx
log time ,1560512917,xxx
log time ,1560522917,xxx
log time ,1560532917,xxx
log time ,1560542917,xxx
log time ,1560552917,xxx
log time ,1560562917,xxx
log time ,1560572917,xxx
log time ,1560582917,xxx
log time ,1560592917,xxx
输出:
Fri Jun 14 17:01:57 CST 2019
Fri Jun 14 19:48:37 CST 2019
Fri Jun 14 22:35:17 CST 2019
Sat Jun 15 01:21:57 CST 2019
Sat Jun 15 04:08:37 CST 2019
Sat Jun 15 06:55:17 CST 2019
Sat Jun 15 09:41:57 CST 2019
Sat Jun 15 12:28:37 CST 2019
Sat Jun 15 15:15:17 CST 2019
Sat Jun 15 18:01:57 CST 2019
2019-06-17
阅读(5927) | 评论(0) | 转发(0) |