banjocode Save Output to a Variable in a Bash Script

Save Output to a Variable in a Bash Script

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

1 min read

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