Two ways to shell command substitution _linux Shell

Source: Internet
Author: User
Tags diff

Command substitution means that the Shell executes a command and replaces the command substitution with the result of executing the command.

There are two ways to replace a command:

1. Use backtick symbols (i.e. ..., inverted quotes, accented symbols).

Copy Code code as follows:

For i in ' cd/old/code/dir; Echo *.c '
Todo
Diff-c/old/code/dir/$i $i | More
Done

2. Use the $ (...) method.

Copy Code code as follows:

For I in $ (cd/old/code/dir echo *.c)
Todo
Diff-c/old/code/dir/$i $i
Done | More

Note: When using the first method, the embedded Backtick symbol and double quotation mark need to be escaped. In the second way, the inline parentheses do not need to be escaped.

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.