Basic Bash Shell command--3

Source: Internet
Author: User
Tags echo command

Environment variables in the shell become global variables and local variables. Global variables take all caps.

1.printenv

View the global variables for the system.

Displays the value of a single environment variable using the echo command.

Eg:echo $PATH Displays the contents of the PATH environment variable.

2.set

Displays all environment variables that are set for a particular process, including global variables.

3. Setting Local Environment variables

Local variables defined in the shell environment cannot be used in their child shells.

Eg:test=testing If you want to assign a value to a variable string that contains a space, you should use single quotation marks. (test= ' Testing a word ')

Echo $test defines the test variable and outputs

4. Setting Global Environment variables

Define the local variables first, and then export the local environment variables to the global environment using export. The global variable is visible in all child processes created by the process that set the global environment variable.

Eg:test= ' Testing a word '

Export Test

Bash

echo $test output Testing a word

5.unset

Delete an environment variable that already exists.

Eg:unset Test

6. Variable array

An environment variable is a good feature that can be used as an array.

Eg:test={one three Four Five}

echo $test Output One

echo ${test[2]} output three

echo ${test[*]} output one three four five

Test[2]=six modifying the third data of an array

echo ${test[*]} output one and six four five

unset Test[2] Delete the third data of the array

echo ${test[*]} output one and four five

echo ${test[2]} output is empty

7.alias

Create an alias for common commands (along with their parameters). The alias can only be valid in the shell process in which they are defined.

Eg:alias li= ' Ls-il '

Basic Bash Shell command--3

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.