ping加上时间信息

发布于 2021-08-26  411 次阅读


[root@comso50 ~]#ping www.baidu.com -c 10 | awk '{ print $0"\t" strftime("%Y-%m-%d %H:%M:%S",systime())}'
###将当前的信息打印到一个文件中
[root@comso50 ~]#ping 115.239.211.112 | awk '{ print $0"\t" strftime("%Y-%m-%d %H:%M:%S",systime()); fflush()}' >> outIP.info &
 ###注意:使用  fflush() ,不然文件不会有信息,因为awk也是有缓存的。