Sleep infinitely in bash

2021-12-19 1 min read Learning bash

I am sure that you would have got a lot of instances where you have wanted to sleep for infinity and ended up doing this

1
2
3
4
while [[ 1 ]]
do
	sleep 3600
done

or some other such similar loop to sleep for some time and wrap it in infinite loop.

I learned something new recently and found it very useful. You can do the above with

1
sleep infinity

and you can use that even for a while loop

1
2
3
while [[ infinity ]]
do
done

Enjoy 👍

comments powered by Disqus