Bash sleep in milliseconds Bash sleep in milliseconds bash bash

Bash sleep in milliseconds


Make sure you're running your script in Bash, not /bin/sh. For example:

#!/usr/bin/env bashsleep 0.1

In other words, try to specify the shell explicitly. Then run either by: ./foo.sh or bash foo.sh.

In case, sleep is an alias or a function, try replacing sleep with \sleep.


Some options:

read -p "Pause Time .5 seconds" -t 0.5

or

read -p "Continuing in 0.5 Seconds...." -t 0.5echo "Continuing ...."


Bash was complaining about decimal values,

read: 0.5: invalid timeout specification

I came around with this solution which works great.

sleep_fraction() {  /usr/bin/perl -e "select(undef, undef, undef, $1)"}sleep_fraction 0.01428