Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Display current nanosecond

984266Feb 6 2013 — edited Mar 11 2013
Hi,

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>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2013
Added on Feb 6 2013
2 comments
464 views