EPOCHSECONDS

A bash 5 variable holding the current time as the number of seconds since 1 January 1970 UTC, known as Unix time.

In more detail

Reading it costs nothing, unlike running date +%s, which starts a new process each time. Subtracting two readings gives an elapsed time in whole seconds, handy for timing a step in a script.

Example

start=$EPOCHSECONDS; sleep 2; echo $((EPOCHSECONDS - start))

Related terms

Taught in

References