@Cykelero didn't want to believe you, so I tried it and now I'm staring at my screen in disbelief
#!/usr/bin/env bash
SECONDS=3
for i in $(seq 1 10); do
echo $SECONDS
sleep 1
done
yields
$ ./ohno.sh
3
4
5
6
7
8
9
10
11
12
Top-level
@Cykelero didn't want to believe you, so I tried it and now I'm staring at my screen in disbelief
yields
5 comments
@eisfunke @Cykelero @jakehamilton the actual use of the variable is to count the number of seconds since the bash instance was started - you don't have to assign anything to it but assigning a value resets it to that value (and it normally only works with the uppercase SECONDS). Bash also offers $RANDOM (you can guess what it does) as well as $EPOCHSECONDS and $EPOCHREALTIME for the more exotic ones. And.. many more (https://www.gnu.org/software/bash/manual/bash.html#Bash-Variables) |
@eisfunke @Cykelero
Imagine the debugging madness this ensues