Sleep infinitely in bash

2021-12-19 94 words 1 min read

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 👍


Tags: Learning bash

Related Articles:


author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it