hankknight
asked on
Linux: execution time to 1000th of a second
#!/bin/bash
t1=$( date +"%s" )
sleep 1.23
t2=$( date +"%s" )
DIFF=$(( $t2 - $t1 ))
echo "Exicution time: $DIFF seconds"
I want the results to be like1.234 seconds
Sorry that *1000 is incorrect.
That should be
You can then add scale to bc to limit this to 3 digits. (or however many.)
That should be
#!/bin/bash
t1=$( date "+%s.%N" )
sleep 1.23
t2=$( date "+%s.%N" )
echo "$t2 - $t1"
DIFF=$(echo "( $t2 - $t1 )" | bc)
echo "Exicution time: $DIFF seconds"
You can then add scale to bc to limit this to 3 digits. (or however many.)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@woolmilkporc
Sorry about that. I have not been posting here in a while.
I was not aware of this rule.
Sorry about that. I have not been posting here in a while.
I was not aware of this rule.
Open in new window
See also
<Link removed by woolmilkporc, EE TA>