Get date with nanoseconds on MacOS

Recently I tried to run my own simple bash script (written on Linux) on my Mac and I found that results are bad because a “date” function.

So the problem is – date on MacOS doesn’t have nanoseconds option.

Solution is simple: install “coreutils” from MacPorts

$ sudo port install coreutils

that’s it!

Now GNU version of the date is available as gdate:

$ gdate +%s%N
1379413863366167000