social.outsourcedmath.com

Just discovered in amazement that in Bash scripts, any variable named `SECONDS` will automatically increment every second. Bash is bonkers
didn't want to believe you, so I tried it and now I'm staring at my screen in disbelief
#!/usr/bin/env bash<br><br>SECONDS=3<br><br>for i in $(seq 1 10); do<br>    echo $SECONDS<br>    sleep 1<br>done<br>

yields
$ ./ohno.sh<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>

This website uses cookies to recognize revisiting and logged in users. You accept the usage of these cookies by continue browsing this website.