expansion
Bash Command substitution
Substitutes stdout and removes trailing newlines; quote the result to preserve whitespace.
Formal Syntax & Structure
bash syntaxbash
$(command)Return Value
shell behavior
Substitutes stdout and removes trailing newlines; quote the result to preserve whitespace.
Working Example
Example Snippetbash
text=$(printf 'one\ntwo\n\n')printf '[%s]\n' "$text"