Email or username:

Password:

Forgot your password?
Top-level
Daniel Terhorst-North

@Cykelero you are just referencing a magic variable called SECONDS built into bash (and zsh). There are a few others that do ‘interesting’ things too!

6 comments
Grumpy Old Techie 🕊️

@tastapod @Cykelero /bin/sh on FreeBSD doesn’t do that. If we can believe the man page that version of the Bourne shell is with us since 1989

/bin/sh
$ SECONDS=3
$
$ for i in $(seq 1 10); do
> echo $SECONDS
> sleep 1
> done
3
3
3
3
3
3
3
3
3
3

Daniel Terhorst-North

@grumpyoldtechie @Cykelero yep, it’s a bash-ism. Nothing to do with posix Bourne shell. Not sure about ksh.

Daniel Terhorst-North

@grumpyoldtechie @Cykelero looks like ksh also has SECONDS but theirs is more sensible, which is generally true of ksh vs bash in my experience:

unix.stackexchange.com/a/11499

Go Up