Pipelining & redirection (Bash)
Redirect output to a variable
There are more aspects to this question than covered here, but this will usually work:
xargs is a more explicit way of reusing the output of a command. I often use it, when more implicit ways of pipelining like through > or | doesn't work, like with WP-CLI. See xargs for details.