var=$(command-name-here) var=$(command-name-here arg1) var=$(/path/to/command) var=$(/path/to/command arg1 arg2)
OR use backticks based syntax as follows to assign output of a Linux command to a variable:
var=`command-name-here` var=`command-name-here arg1` var=`/path/to/command` var=`/path/to/command arg1 arg2`
Examples
## store date command output to $now ## now=$(date)
## alternate syntax ## now=`date`
To display back result (or output stored in a variable called $now) use the echo or printf command:
echo "$now" printf "%s\n" "$now"
References
https://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-bash-assign-variable-command-output/