helpThe GNU Bourne-Again SHell - Support: sr #109599, Can we have nanosecond timestamps...

 
 

sr #109599: Can we have nanosecond timestamps in printf?

Submitted by:  None
Submitted on:  Fri 07 Dec 2018 08:41:48 AM UTC  
 
Category:  None Priority:  5 - Normal
Severity:  1 - Wish Status:  Works For Me
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 20 Dec 2018 04:52:59 PM UTC, comment #1: 

If the OS and its strftime(3) implementation support nanoseconds, you can access them using %(...)T.

Bash doesn't implement any of the time formats itself; it just passes them to strftime().

Chet Ramey <chet>
Project Administrator
Fri 07 Dec 2018 08:41:48 AM UTC, original submission:  

For being more accurate in timing things it would be nice to not have to start any external program and use the built in printf to access the timestamp in nanosecond accuracy (yeah, nano seconds is not really needed but you can always reduce from there, hard to get more accuracy later, and its already there).

Other shells seem to support %N for accessing the nanoseconds part of an internal clock_gettime (or similar) call. If the underlying OS doesn't have one that returns nanoseconds it seems to be appropriate to just scale up, a lot of OSs I have seen return nanoseconds but are really just internally using microseconds and multiply by 1000.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-20 chet StatusNone => Works For Me

    Back to the top


    Powered by Savane 3.5