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