Search code examples
shelldatemillisecondselapsedtime

1394661620440271000/1000000: No such file or directory


I am running this command in my shell script to get time in milliseconds:

    START=`$(date +%s%N)/1000000`

However I keep getting the error:

   1394661620440271000/1000000: No such file or directory

I tried to change the code by adding brackets, extra dollar signs, but I keep getting different kinds of errors. How can I fix the code? Could anyone help with that?


Solution

  • assuming that you're using bash:

    START=$(( $(date '+%s%N') / 1000000 ))
    

    you can't just say / on the command line to divide numbers. (( ... )) does arithmetic evaluation in bash.