Put command output on line

If I execute any command in the linux shell, how can I save the output to a string so that the user can use it later? I need this for a bash script, please help.

+6
source share
2 answers
str=$(command) 

+10
source

result=`command` or result=$(command) both assign the output of command variable result .

+7
source

Source: https://habr.com/ru/post/890291/