Delay for a specified amount of time.
The sleep command pauses the execution for a specified duration.
sleep(parameter)
Time: Specifies the length of time to pause, including:
2s: 2 seconds2m: 2 minutes2h: 2 hours2d: 2 daysinfinity: PermanentlyWhen writing monitoring scripts that run in a loop, setting a time interval is essential. Below is a demonstration of a Shell progress bar script that generates delays.
#!/bin/bash
b=''
for ((i=0;$i<=100;i++))
do
printf "Progress:[%-100s]%d%%\r" $b $i
sleep 0.1
b=#$b
done
echo