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