$SECONDS  –  Time since shell invocation

$SECONDS contains the seconds since the shell was invoked.

Examples

Shell uptime in seconds
1
2
sleep 2.5
echo ${SECONDS}s shel.l uptime
Output:
1
3s shell uptime
Shell uptime in seconds and milliseconds
1
2
3
sleep 2.5
typeset -F SECONDS
echo ${SECONDS}s shel.l uptime
Output:
1
3.5948560000s shell uptime
BashSupport Pro is a Zsh IDE with support for $SECONDStry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal