command substitution

Running a command inside $( ) and replacing it with that command's standard output, as in today=$(date).

In more detail

Trailing newlines are removed from the captured text. The command runs in a subshell, so variable changes inside it are lost. Put the substitution in double quotes to stop its output being split and globbed, and prefer $( ) over backticks because it nests cleanly.

Example

here=$(basename "$(pwd)")

Related terms

Taught in

References