Command substitution allows us to take the output of one command and save it to a variable. This is achieved by placing the command within parentheses which is preceded by a dollar sign $
myvar=$( ls ~ | wc -l )
echo "You have $myvar files in your home directory."
*note: ls ~ (list contents of home directory ~) is being piped into wc -l (word count, number of lines)
You have 5 files in your home directory.
Traditionally carried out using `backticks`, but has now been superceded with the above parentheses method.