Save Output to a Variable in a Bash Script

Save the output of a command in a Bash script to use it later.


Save output to variable in Bash

Saving the output of a command to a variable is quite simple - you use the $() syntax.

VALUE=$(echo hello)

Then you call it as usual.

echo $VALUE