Command execution
Appearance
General
- capture the result of a command's execution for use in the script
- execute a command and put the output of the command into a variable
- The current syntax for this
- $(command)
- The older syntax for this
- `command`
- the result of the $(command) is just the output from the command
- This is the string output, not the return status
Examples
- echo The current directory is $PWD
- Since PWD is a shell ENV, you don't need the special syntax
- echo The current users are $(who)
Assign to a variable
- blah=$(who)
- echo $blah