Bash's variables

Source: Internet
Author: User

Bash the variable

(1) name of the variable

Can contain only letters, numbers, and underscores, and cannot begin with a number;

Should not be the same as the existing environment variables in the system;

It's better to see the name and know it.


(2) Variable Type

Local variables: scoped to the current shell process

Local variables: scoped only to a snippet of code in the current shell process (usually a function context)

Environment variables: scoped to the current shell process and its child processes

Position variable: $1,$2

Special variables: $?


(3) definition of a variable

Define local variables: name=value

View Local Variables: Set

Defining Environment Variables: exportname=value

Declare–xname=value

View Local Variables: env,printenv,export

Undo Variable: unset name

Reference variable: ${name}, $name

Bash the reference symbol in:

"': strong references, variable substitution does not occur

"" : Weak references

``: Command Reference


Shell Login Type:

Interactive login:

Login directly through the terminal;

User Switching implemented by su-l username command;

Non-interactive logon:

A command-line window opens under the graphical interface;

Execute script

Configuration file Action Order:

Interactive login:

/etc/profile-->/etc/profile.d/*.sh--~/.bash_profile-~/.BASHRC-->/ETC/BASHRC the last priority is the highest .

Non-interactive logon:

~/.BASHRC--/ETC/BASHRC-->/etc/profile.d/*.sh

How does the new configuration of the Edit profile definition take effect?

(1) re- login;

(2) Let the current shell process to re-read the specified configuration file;

Source/path/to/somefile

. /path/to/somefile

Note: Duplicate variables are generated


Bash's variables

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.