Table of Contents

Bash - Command substitution

About

command substitution is an expansion that replaces a command expression with the resulting stdout of the command.

Example

Subshell

$( ) executes in a subshell

current_date=$(date)
echo "The current date and time is: $current_date"
echo "The current date and time is: $(date)"

Same shell

Old with backtick `` that executes in the same shell

current_date=`date`