I'm running Ubuntu 18.04 and am new to Ubuntu and Linux in general. I'm trying to measure the execution time of a command down to the millisecond. I would also like to append this time to a file, because I'm doing this a lot of times in a for loop. Finally, I would like to have the most simple and easily readable syntax.
Long story short : I would like the /usr/bin/time command to return a result precise to the millisecond.
I have read other threads mentioning a time format environment variable, but never how to modify it.
Thanks in advance for the help.
EDIT : Taking all answers into account, the solution was something like
#!/bin/bash
ts=$(date +%s%N)
command
echo "formatting $((($(date +%s%N) - $ts)/1000000)) formatting" >> file_to_append_time_to