05.Shell of the universe is a great diversion

Source: Internet
Author: User
Tags echo command

If the expression contains special characters, the Shell will replace it. For example, using a variable in double quotes is a substitution, and an escape character is also a substitution.
As an example:

#!/bin/bash

a=10

Echo-e "The universe is $a \ n"

Operation Result: The universe is a big diversion .

here-e indicates the substitution of the escape character. If you do not use the-e option, the output will be as-is: the big move

The following escape characters can be used in echo:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/83/55/wKiom1dw04nC5BEkAAAff2vW-58644.png "title=" Vvv.png "alt=" Wkiom1dw04nc5bekaaaff2vw-58644.png "/>

You can suppress escaping by using the-e option of the Echo command, which is not escaped by default, or by using the-N option to prevent the insertion of line breaks.


Command substitution

Command substitution means that the shell can execute commands first, save the output temporarily, and output it where appropriate.

Syntax for command substitution:

' Command '

Note that it is an anti-quote, not a single quote, which is below the ESC key.

In the following example, the command execution results are saved in a variable:

#!/bin/bash

Date= ' Date '
echo "Current date is: $DATE"

Users= ' who | Wc-l '
echo "Login user has $USERS"

up= ' date; Uptime '
echo "Time: $UP"


Operation Result:

The current date is: Mon June 00:28:39 PDT 2016 login users have 2 times: Mon June 00:28:39 PDT 00:28:39 up 5:29, 2 users, load average:0. 00, 0.00, 0.00

Variable substitution



The variable substitution form you can use:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/83/55/wKiom1dw1gTzpfjYAABTRoNac-0150.png "title=" Xxx.png "alt=" Wkiom1dw1gtzpfjyaabtronac-0150.png "/>


An example:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/83/55/wKiom1dw2BTgH8K1AAA3wH-QPu4501.png "title=" Yyy.png "alt=" Wkiom1dw2btgh8k1aaa3wh-qpu4501.png "/>


This article is from the "8159085" blog, please be sure to keep this source http://8169085.blog.51cto.com/8159085/1793310

05.Shell of the universe is a great diversion

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.