码迷,mamicode.com
首页 > 系统相关 > 详细

Linux awk 在文件每行后面增加个时间戳

时间:2017-08-30 13:03:37      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:shutdown   mit   seq   pre   div   ...   tran   receive   statistic   

[root@localhost ~]# for line in `cat /etc/passwd`;do echo $line|awk { print $0"   " strftime("%Y-%m-%d %H:%M:%S",systime())} && sleep 2;done
root:x:0:0:root:/root:/bin/bash   2017-08-30 11:34:01
bin:x:1:1:bin:/bin:/sbin/nologin   2017-08-30 11:34:03
daemon:x:2:2:daemon:/sbin:/sbin/nologin   2017-08-30 11:34:05
adm:x:3:4:adm:/var/adm:/sbin/nologin   2017-08-30 11:34:07
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin   2017-08-30 11:34:09
sync:x:5:0:sync:/sbin:/bin/sync   2017-08-30 11:34:11
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown   2017-08-30 11:34:13
.....................................


[root@localhost ~]# ping -c 5 www.baidu.com | awk { print $0" " strftime("%Y-%m-%d %H:%M:%S",systime())}
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data. 2017-08-30 11:36:53
64 bytes from 14.215.177.38: icmp_seq=1 ttl=54 time=7.35 ms 2017-08-30 11:36:53
64 bytes from 14.215.177.38: icmp_seq=2 ttl=54 time=6.75 ms 2017-08-30 11:36:54
64 bytes from 14.215.177.38: icmp_seq=3 ttl=54 time=6.83 ms 2017-08-30 11:36:55
64 bytes from 14.215.177.38: icmp_seq=4 ttl=54 time=6.85 ms 2017-08-30 11:36:56
64 bytes from 14.215.177.38: icmp_seq=5 ttl=54 time=5.84 ms 2017-08-30 11:36:57
 2017-08-30 11:36:57
--- www.a.shifen.com ping statistics --- 2017-08-30 11:36:57
5 packets transmitted, 5 received, 0% packet loss, time 4013ms 2017-08-30 11:36:57
rtt min/avg/max/mdev = 5.840/6.727/7.358/0.503 ms 2017-08-30 11:36:57

 

Linux awk 在文件每行后面增加个时间戳

标签:shutdown   mit   seq   pre   div   ...   tran   receive   statistic   

原文地址:http://www.cnblogs.com/chenjinxi/p/7452287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!