UNIX System Management: Shell Advanced Features

Source: Internet
Author: User
Keywords UNIX System Management advanced features
Tags advanced advanced features command line created data environment function local

To complete this chapter, you can do the following things:

Use the Shell's alternative function, including variable substitution, command substitution, and tilde substitution.

Set up and modify shell variables.

Pass local variables to the environment.

Make the variable take effect on the child process.

Explains how the process was created.

7.0 Shell substitution function

There are three types of substitutions in the shell:

Variable substitution

Command substitution

Wave substitution

The alternative is to speed up the typing and execution of the command line

7.1 Shell Variable Storage

There are two memory areas in the shell for storing shell variables: Local data regions and environments. When a new variable is defined, the memory is assigned to the local data region, where the variable is the current shell private, often called a local variable, and no subsequent subprocess will access the local variables. However, a child process can access variables that are transferred to the environment.

During your login process, there are several special shell variables that are defined. Most of these variables are stored in the environment: some variables, such as PS1 and PS2, are stored in the local data area. The values of these variables can be changed to customize your terminal features.

The env command can display all variables currently stored in the environment, such as:

$ env

Manpath=/usr/share/man:/usr/contrib/man:/usr/local/man

Path=/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/local/bin

Logname=user3

Erase=^h

Shell=/usr/bin/sh

Home=/home/user3

Term=hpterm

Pwd=/home/user3

Tz=pst8pdt

Edtor=/usr/bin/vi

7.2 Set the shell variable

Syntax: http://www.aliyun.com/zixun/aggregation/11696.html ">name=value

Example:

$ color=lavender? ? ??????? Assign a value to a local variable

$ count=3????????????? ? Assign a value to a local variable

$ Dir_name=tree/car.models/ford? Assign a value to a local variable

$ ps1=hi_there?????????? ?? Change the value of an environment variable

$ set??????????? ????? Show all variables and values

When a user creates a new variable, such as color, the variable is stored in the local data area. When an existing environment variable is given a new value, such as path, the new value replaces the old value in the environment.

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.