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