RESULT=$(command)

Category: Bash Scripting

RESULT=$(command)

Capture the output of a command in a variable

Runs a command and captures its output (what it would print to the screen) into a variable.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.