bash - how to get a command's output to a variable
BASH command output to the variable has great examples of how to do this. Basically, it boils down to something like this:
variable=$(command)
variable=$(command [opotion...] arg1 arg2 ...)
variable=$(/path/to/command)
You can also use the "`" as well, with all the caveats of using it in bash entails.
Code or Examples
START_TIME=$(date)
#### ... stuff happens here
printf "started: ${START_TIME}\n"
printf "finished: $(date)\n\n"
The sample above is from one of my scripts and it works quite nicely.