Shell variables are divided into system variables and user-defined variables
commands to view variables
#env System Variables
Or #set include env and custom variables and extra variables
The command to use the variable is
#echo $ "Variable"
/////////////////////////////////////////////////////////////////////////////
1. Custom variables
It is recommended to use lowercase to differentiate system variables.
[Email protected] 111]# a=1
[Email protected] 111]# echo $a
1
[Email protected] 111]# a=1;b=2;c=3
[Email protected] 111]# echo $a $b $c
1 2 3
[Email protected] 111]# echo $a $b$c
123
2. Single quotes for variables of special characters
[Email protected] 111]# a= ' ... +++--**//'
[Email protected] 111]# echo $a
...+++--**//
3. Using the command to run the result with the inverted quotation mark
[Email protected] 111]# a= ' ll 1.txt '
[Email protected] 111]# echo $a
-rw-r--r--1 root root 4 November 22:03 1.txt
=
4. Let the variable overlay with double quotation marks
[Email protected] 111]# a=1
[Email protected] 111]# b= "$a" 2
[Email protected] 111]# echo $b
12
////////////////////////////////////////////////////////////////////////////////////////////
Global Declaration
Command: Export
Description: Global declaration
[Email protected] 111]# d=5
[Email protected] 111]# echo $d
5
[[email protected] 111]# bash////enters child shell variable a fails
[Email protected] 111]# echo $d
[[Email protected] 111]# exit//exit child shell
Exit
[[email protected] 111]# export d=6//Global declaration
[Email protected] 111]# echo $d
6
[[email protected] 111]# Bash//Enter child shell
[Email protected] 111]# echo $d
6
/////////////////////////////////////////////////////////////////////////////////////////////////////////
Summary: A=1, echo $a//a=1;b=2;c=3 echo $a $b$c//a= ' + +. --'//a= ' cat 1.txt '//a= "$b" 1//Export a=1, bash, echo $a//
Shell Getting Started-variables