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?
Use the time command. Note that the bash version of time is not the same as /usr/bin/time. So you would have something like:
TIME=`/usr/bin/time --format="%e" your_command_here >/dev/null`
The format just pulls the "real" time value out. You would need to convert that from a string if you wanted to do anything more than display it.
If you just want to export the string, use export
.