Is there a pause with nanoseconds in bash?

Is there a way to get Unix Time with nanoseconds with strftime in bash?

My line for unix time:

<command> |  awk '{ print strftime("%s"),  $0; }'

I cannot use date +% N because the date is evaluated only once.

Is there any work?

+3
source share
2 answers

I found a workaround while reading. date is updated in this way. No need for strftime.

<command> |  while read line; do d=`date +%s%N`; echo $d $line; done
+4
source

You can still use date

ls | xargs -IQ date "+%s.%N Q"

It’s just that you don’t have% in your output ... (but you can get around this too)

0
source

Source: https://habr.com/ru/post/1758284/


All Articles