% Shell Command Substitution -- interpolate *stdout* into a command line using $(...) or \`...\` % Ian! D. Allen -- -- [www.idallen.com] % Fall 2015 - September to December 2015 - Updated 2017-12-20 11:15 EST - [Course Home Page] - [Course Outline] - [All Weeks] - [Plain Text] Shell Command Substitution -- interpolate *stdout* into a command line ====================================================================== You are already familiar with the shell interpolating text into a command line from a variable, e.g. $ var="Hello Mother" $ echo "I said: $var" I said: Hello Mother The shell can also interpolate text that is the standard output (**stdout**) of a command or list of commands using a similar syntax to variable substitution. This is called **Command Substitution**. The syntax for **Command Substitution** to interpolate the output of a command line into another command line uses a dollar sign and matched parentheses with the command line (any command line!) inside the parentheses: $ whoami idallen $ echo "Your userid is $(whoami) on this system." Your userid is idallen on this system. $ date Thu Nov 19 11:58:55 EST 2015 $ echo "The date is $(date) today." The date is Thu Nov 19 11:58:59 EST 2015 today. $ wc -l