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

 
 

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

Submitter:  None
Submitted:  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
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

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>
Group 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

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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

    Votes

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

    History

    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.16-2753.
    Corresponding source code