Common Linux Commands Explanation (sixth day)--shell environment variables

Source: Internet
Author: User

Too lazy, these days seem to have been lazy cancer, do not want to write a blog. Later think about, knowledge, or share the good. The first to cure their own lazy cancer; second, consolidate your knowledge by the way.

There are two types of Linux variables, one is the system variable, and the system is written into the memory variable once it is started. Can be called in various processes, as well as in child processes.

A variable that is set by itself, after shutting down and then turning it off, or cutting to the next process, you cannot find the variable. This is a local variable.

The above two variables, the fifth day when there is a detailed narration, here will not repeat.

To view environment variables there is a command: Env env is the meaning of environment "environment".

There are some constants that we use frequently, such as home, SHELL, Histsize, MAIL, PATH, LANG, random, and so on. These words are very good to know, Gu Ming thought. Therefore no further explanation will be continued.

View all the variables that are set by the current system constant and itself. Can be viewed with the set command.

Let's go ahead and talk about the difference between Env's environment variable and set's custom variable there are those: (referring to the bird's-brother Linux Private Cuisine 11th chapter) The difference is whether the variable will be the quilt process continues to reference, then what is the parent process, what is a child process. When you log in to Linux and get a bash, your bash is a standalone process that is the PID. Then any commands you execute under this bash are derived from this bash, and the commands that are executed become sub-processes. (Great brother Bird, it's good to write.) )

In my fifth day note, I raised a question about how to set the variable I set as an environment variable. Now we can use the Export command. Export in English means output, exit, take away, carry away;

It means changing the variable you set into an environment variable.

global variable = environment variable

Local variable (locals) = local variable

Why can the data of the environment variable be referenced by the quilt process? This is because of the relationship of the memory configuration. This is theoretically the case:

1. When a shell is started, the operating system assigns a dedicated area to the shell for use. The variables in this memory allow the child process to call,

2, if the parent process using the export function, you can let the custom variables loaded into the above memory block.

3. When another shell is loaded, the child process is started. Leave the original parent process. A child shell, which can be used to import memory blocks from the environment variables of the parent shell into its own environment variable block.

The previous variable is somewhat interesting. Down we continue to look at something more interesting. Actually a bit if and else judge.

I remember installing the one-click Lamp Install package in front of me, I chose to use that version of MySQL and that version of PHP, as well as the installation path, the default password and so on. It was curious how this step-by-step guide was written. That's what we're going to see in the next read command.

The syntax of the command is this. Read [-PT] Variable

This-p command refers to print. Can be viewed in detail through the man Read command.

This-t refers to the maximum number of seconds that the user is allowed to wait behind. Come on. Let's see how it's used.

The select variable that follows me can be used to get a yes or No on the keyboard.

Here's a way to declare a variable. Declare is a declaration of the meaning of the announcement.

Declare-a is the meaning of declaring an array. A represents an array of things type.

Declare-i is the meaning of declaring an integral type, I represents an integer (integer)

Declare-x can change the following variable into an environment variable. X is for the export, perhaps the pronunciation is a bit of the beginning of x, so it is named after X.

Declare-r is a variable (variable) that can be set to read-only type. R stands for readonly.

Declare the default type is a string if it does not have a reputation type.

A numeric budget in a bash environment that can reach up to only integer types by default.

Below we practice the above mentioned knowledge points through a small Li Zilai.

Let's look at the usage of Declare-x.

Let's look at the usage of declare-r.

These several options can be used in combination.

This blog is actually written this week in Monday or Tuesday. But this week's physical and mental state is not very good. As a result, blogs are not continuously updated.

Although I know that the blog in the Garden of Daniel gathered, for my share of the fundamental disdain. But it's going to go on.

By the way to talk about their own sentiment: time really will make a person happen Sanghaisanda great changes. Some friends are only suitable to remember, some people only fit to remember. We are all rolling with the tide of time, is washed away and no longer like once. Perhaps become more kind, perhaps become more sensitive, perhaps become more optimistic. In short, are not the past people, put in the list of friends, the night of insomnia when you look at the time, there are friends who have been the donkey. This is just enough, if you can keep in touch for a long time, it must cherish, this is really god-given fate.

Interpretation of Common Linux commands (day sixth)--shell environment variables

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.