In addition to the backticks, you can use
Quoting (
Src: http://stackoverflow.com/questions/4651437/how-to-set-a-bash-variable-equal-to-the-output-from-a-command
$()
, which I find easier to read, and allows for nesting.
OUTPUT="$(ls -1)"
echo "${OUTPUT}"
Quoting (
"
) does matter to preserve multi-line values.Src: http://stackoverflow.com/questions/4651437/how-to-set-a-bash-variable-equal-to-the-output-from-a-command
No comments:
Post a Comment