Command Substitution
command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed with a beginning dollar sign and parenthesis, $(command), or with back-ticks, 'command' . The form with back-ticks is older, and has two disadvantages;
command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed with a beginning dollar sign and parenthesis, $(command), or with back-ticks, 'command' . The form with back-ticks is older, and has two disadvantages;
- it can be easy to visually confuse back-ticks with single quote marks
- back-ticks cannot be nested inside back-ticks.
The $(command) form can nest multiple command expansions inside each other.
date +%A
echo The time is $(date +%M) minutes past $(date +%I%p)
Tech info |
Comments
Post a Comment