Array variable read-only variable delete variable environment and shell variable
I'm finally going to start writing shell scripts. Array Variables
Create an array variable by assigning values directly to the array's index:
Array[index]=value
Note: Index is a range of values [0, 1023]
If a scalar name and array name are duplicate, then the value of the scalar corresponds to the value of the array 0 index
Another way to initialize an array, you can assign a value to multiple elements at once
The way of Access is also given above
The form is like this: ${array[index]}
Use this way to access all elements in an array echo ${array[*]}
If we define an array element such as: fruit[3]= "passion Fruit"
So when we access the array using ${fruit[*]}, the shell interprets the array as 5 items, and then we need to use ${fruit[@]} to let the shell know that we want to output 4 items
I don't really see what's too big difference. read-only variable
You can set a variable to read-only by using the ReadOnly command, which is equivalent to the const keyword in a high-level language and can only be modified one time to delete a variable at initialization time
To delete a variable using the unset command, thereadonly variable cannot be deleted
environment and Shell variables
First, let's illustrate the concept of environmental variables:
when the shell runs a program, it passes a set of variables to the program called the environment. The environment is usually a small subset of all the variables defined by the shell. Every variable in the environment is called an environment variable
In addition to local variables and environment variables, there is also a variable called a shell variable
Some shell variables are environment variables, some are local variables
The output environment variable uses the command export name, which means that local variables are placed in the environment through the Export command