如何在不显示时间的命令的输出中强行插入时间?

我使用【iftop -P -l -n -N -B -t】来监控网络,直接输出到日志。
但我发现这款工具,居然不记录时间。

因此,像这种不输出时间的监控工具,如何在它的输出里强行加入时间?

难道只能改源码吗?
谢谢~

阅读 3.6k
1 个回答

awk啊,例如我ping百度:

$ ping www.baidu.com | awk '{ print $0"\t",system("date")} '
PING www.a.shifen.com (119.75.217.109): 56 data bytes     2016年 2月25日 星期四 23时22分45秒 CST
0
64 bytes from 119.75.217.109: icmp_seq=0 ttl=48 time=31.877 ms     2016年 2月25日 星期四 23时22分45秒 CST
0
64 bytes from 119.75.217.109: icmp_seq=1 ttl=48 time=32.985 ms     2016年 2月25日 星期四 23时22分46秒 CST
0
64 bytes from 119.75.217.109: icmp_seq=2 ttl=48 time=31.856 ms     2016年 2月25日 星期四 23时22分47秒 CST
0
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题