-------------------------------------- Command Substitution - $(unix command) -------------------------------------- -Ian! D. Allen - idallen@idallen.ca Command Substitution is similar to variable substitution; but, it is the standard output of the given Unix command that is substituted. The command line is executed and all the standard output is captured and becomes the result of the substitution. - syntax: $( any Unix command goes between parentheses ) - *all* the standard output of the command(s) between parentheses is captured - *only* the standard output, not standard error - Typical use is to assign command output to a shell variable: $ users=$( who | wc -l ) $ echo "Number of users logged in: $users" $ words=$( wc -w