Email or username:

Password:

Forgot your password?
Top-level
Nicolas :eisfunke_logo:

@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
5 comments
Steven Reed

@eisfunke @Cykelero one of the few pleasures of getting old is watching people significantly younger than me being weirded out by this sort of thing for the first time :)

Heals :heart_nb: (comms open)

@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 (gnu.org/software/bash/manual/b)

Go Up