I tried using t1=$(date +%s%N)
to get the time in nanoseconds, but I kept in getting this error:
./script.sh: line 10: 1292460931N: value too great for base (error token is "1292460931N")
I looked up online and it seems that you can use the "time" command, however I can't find a good example of using the time command. Any help would be appreciated :)
date +"%T. %6N" returns the current time with nanoseconds rounded to the first 6 digits, which is microseconds. date +"%T. %3N" returns the current time with nanoseconds rounded to the first 3 digits, which is milliseconds.
It is as easy as typing sleep N . This will pause your script for N seconds, with N being either a positive integer or a floating point number.
The date
command you're using doesn't support %N
so your output is literally 1292460931N
. I tried it on Linux and it worked, but on FreeBSD I see the results you got. Run that date command in a shell and see what comes out. Is it possible you're using busybox
? Its cut-down date command also omits %N
but the version I just tried gave me 1292463535%N
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With