Linux Bash Shell Basic syntax

Source: Internet
Author: User

The use and setting of a variable (note that there can be no spaces before and after the equals sign)

1. Read

Read the input from the keyboard assignment to the variable, using the following method

[Email protected]:/opt/android-sdk/sdk/# read Var_readthis is ' What I get ' from my Keyboard[email protected]:E Cho  ${var_read}this is that I get from my keyboard

2. Declare

Declare variables, if not add declare when defining variables, actually the same effect

[Email protected]:/opt/android-sdk/sdk/# declare a=hw[email protected]:/opt/android-sdk/sdk/# b=hw[ Email protected]:echo  ${a}hw[email protected]:echo  ${b}hw

Also, if the DECLARE command has another syntax:

-A sets the following variable to array

-I set the integer to the back of the change

-R Sets the following variable to read-only

3. Export

Change the following variable into an environment variable, which can be seen in all shells

[Email protected]:/opt/android-sdk/sdk/# var_1=hw[email protected]:/opt/android-sdk/sdk/# Export var_1 [Email protected]:/opt/android-sdk/sdk/# export VAR_2=HW

4. Array

How to define an array: var[index]=content

Linux Bash Shell Basic syntax

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.