About the shell in the command to replace the $ (...) Different from the post reference ' ... '

Source: Internet
Author: User
Command substitution

In bash, $( ) and ` ` (anti-quote) are used for command substitution.
command substitution is similar to variable substitution, which is used to reorganize the command line, complete the command line in quotation marks, and then replace the result with the new command line.

$ () and '

In the operation, both are to achieve the corresponding effect, but the recommended use $( ) , for the following reasons:

  • ' It's easy to mess with ', especially for beginners.
  • In a multi-layered compound substitution, ' you have to have extra hops (backslashes), and $ () is more intuitive.
  • Finally, the downside of $ () is that not all UNIX-like systems support this approach, but the anti-quotes are definitely supported.
# cmd1 execution result as cmd2 parameter, and then CMD2 result as cmd3 parameter Cmd3 $ (CMD2 $ (CMD1)) # If you use anti-quote, direct reference is not possible, also need to do a jump-off processing cmd3 ' cmd2 \ ' cmd1\ '

  

About the shell in the command to replace the $ (...) Different from the post reference ' ... '

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.