I need a timer that will work with milliseconds. I tried using the sleep 0.1 command in the script. I see an error message:
syntax error: invalid arithmetic operator (error token is ".1")
When I run sleep 0.1 in the terminal, it works fine.
Please help me!
EDIT: Sorry, I made a mistake:
function timer { while [[ 0 -ne $SECS ]]; do echo "$SECS.." sleep 0.1 SECS=$[$SECS-0.1] done }
Line sleep 0.1 was 5th, and SECS=$[$SECS-0.1] was 6th. I just crippled the lines. The problem was in the 6th line, because bash cannot work with floating point numbers. I changed my function as below:
MS=1000 function timer { while [[ 0 -ne $MS ]]; do echo "$SECS.." sleep 0.1 MS=$[$MS-100] done }
bash sleep timer
Noqrax
source share