shell – 如何在FreeBSD中获得以毫秒为单位的时间?

前端之家收集整理的这篇文章主要介绍了shell – 如何在FreeBSD中获得以毫秒为单位的时间?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Linux中,我可以使用以下命令找到当前时间(以毫秒为单位): @H_404_1@date +%s%N

但是在FreeBSD上,我只得到了

@H_404_1@[13:38 ]#date +%s%N 1299148740N

如何在FreeBSD中获得以毫秒(或纳秒)为单位的时间?

使用gettimeofday(),例如: @H_404_1@#include <stdio.h> #include <sys/time.h> int main(void) { struct timeval time_now; gettimeofday(&time_now,NULL); printf ("%ld secs,%ld usecs\n",time_now.tv_sec,time_now.tv_usec); return 0; }

猜你在找的Bash相关文章