Display current nanosecond
984266Feb 6 2013 — edited Mar 11 2013Hi,
I need to write a script to write a current nanosecond time stamp to a file
The time stamp should looks like ls -lE output.
I have try the man page for date, it seems that there are no options for displaying nanosecond
And I have try the following method, it also doesn't seems the same as ls -lE
=============================
root@newUAT> /usr/sfw/bin/gcc /tmp/time_ms.c -o /var/tmp/time_ms
root@newUAT> date +%H:%M:%S.`/var/tmp/time_ms|cut -d . -f2`
15:36:07.366
root@newUAT> cat /tmp/time_ms.c
#include <sys/time.h>
main()
{
struct timeval tv;
gettimeofday(&tv,(void*)0);
printf("%d.%d\n",tv.tv_sec,tv.tv_usec/1000);
}
root@newUAT> date +%H:%M:%S.`perl -e 'print time()*1000;print "\n";'`
15:36:38.1360136198000
root@newUAT>