Friday, December 7, 2012

Shell scripting - sleep for milliseconds

Ever tried to make your shell script sleep for milliseconds? I tried, and failed miserably in doing so. I didnt know that decimal numbers are not allowed after the sleep command.

I found the following command that could be used for "virtually simulating" the millisecond sleep command:

typeset -i count=0;
while [[ ${count} -le 5700 ]];
do
      count=${count}+1
done

decrease the value 5700 to a value which would suit your needs. 5700 gives you ~1 sec time.