Command substitution

Command substitution allows the output of a command to be stored in a variable; the command can be replaced by itself. There are two methods for performing command substitution:

  • Enclosing the command within backticks, as in `command`. Use of backticks is an older method, and has two disadvantages:
    • Backticks are sometimes confused with single quotation marks
    • Backticks cannot be nested inside other backticks, so nested command substitution is not possible
  • Enclosing the command with an initial dollar sign and parentheses, as in $(command). This overcomes the disadvantages of backticks when used in command substitution as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.221.52