Fundamentals7 / 17
Up next

Command substitution

#!/usr/bin/env bash
# $(...) runs a command and substitutes its stdout
today=$(date +%Y-%m-%d)
words=$(echo "one two three" | wc -w)
echo "date=$today words=$words"
What you're solving

capture a command's output with $(...)