2 # Desc: Get timestamp in nanoseconds
5 # Desc: Get epoch nanoseconds
9 # Output: Nanoseconds since 1970-01-01
11 local currentTime epochSeconds fracNanosec epochNanosec
12 currentTime
="$(date +%s.%N)";
13 epochSeconds
="$(echo "$currentTime" | cut -d. -f1)";
14 fracNanosec
="$(echo "$currentTime" | cut -d. -f2)";
15 epochNanosec
="$(( ("$epochSeconds" * 1000000000) + ("$fracNanosec") ))";
17 } # Nanoseconds since 1970-01-01
19 #==BEGIN sample code==
20 echo "It's been $(timeEpochNS) nanoseconds since 1970-01-01.";
23 # Author: Steven Baltakatei Sandoval