Bash scripting seven Save the command output to a variable (reprint)

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/csfreebird/article/details/7978699

' symbol contains commands that can be saved to a variable after the command has been executed

    #!/bin/Bash             v= ' java-version '      echo $v  

Execution Result:

    $./install.sh      "1.6.0_34"      1.6. 0_34-  B04)      20.9

', English is Backtick, accent.

There is another way to wrap the commands in $ ().

    #!/bin/Bash             v=$ (Java-version)      echo $v  

The execution results are the same.

This approach allows embedding commands, but I don't know how to use them.

Backtick's way of readability is better, with more. I used it for a few service scripts.

Bash scripting seven Save the command output to a variable (reprint)

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.