I want to run a process in bash and save in an env variable the number of seconds it took to run. How would I do such a thing?
This works in Bash, and also Zsh:
# Set time format to seconds
TIMEFORMAT=%R
# Time a process
PROC_TIME=$(time (insert command here >/dev/null 2>&1) 2>&1)
echo $PROC_TIME