Passing output to variable instead of file

Hi,

In normal shell scripting, how do you pass the output of a command to a variable, instead of a file and be able to use it later?
The code is:

#!/bin/bash

who | cut -d" " -f1 > onlineusers

Instead of passing the output of the above command to the file called 'onlineusers' highlighted in red, how do you pass the output to a variable or to any other sort of container and could be made use of later?

Like this:

variable=$(who | cut -d" " -f1)
variable=`who | cut -d" " -f1`