Terminal: terminal attached to the interface program:
GUI: KDE, GNOME, Xfce
CLI:/etc/shells,
Characteristics of the bash: command hash (mechanism to accelerate the search command)
Role: previous command cache lookup results: key-value
key: the search key
value: value
hash command:
hash: list
hash -d COMMAND: Delete
hash -r: Empty
Characteristics of the bash: Variable
Procedure described embodiment 1: instruction data +
Instructions: providing a file;
Data: IO devices, files, pipes, and other variables
Procedure described embodiment 2: Algorithms + Data Structures
Variables: variable name + points to memory space
Variable assignment: name = value
Variable type: variable storage format is defined, data indicating the range, the operation involved in
Programming language:
Strongly typed language variables
Weakly typed language variable: bash
All variables were all considered to bash the character; does not support floating-point data
bash the variables without prior declaration; equivalent, the statement and assignment process while achieving
Disclaimer: type, variable names defined variables
Variable substitution: replace the position variable name appears as it points to the data memory space;
Variable references: $ {var_name}, may be omitted in most cases {}
Variable names: Variable names can only contain numbers, letters and underscores, and can not start with a number;
Variable naming rules: see to know the name of justice, naming follow a rule; can not use the reserved word program, such as if, else, then, while, and so on;
bash variable type:
- Local variables: scope only for the current shell process;
- Environment variables: the scope of the current shell process and its children;
- Local variables: Scope only a code fragment (function context);
- Location parameter variables: Parameter shell process script execution when passed;
- Special variables: shell variables have special built-in functions, such as the $?
Local variables:
Variable assignment: name = value
Variable references: $ {name}, $ name
View variable: set
Undo variable: unset name (here non-variable references)
Environment variables:
Variable assignment:
(1) export name=value
(2) name=value
export name
(3) declare -x name=value
(4) name=value
declare -x name
Variable references: $ {name}, $ name
bash built a number of environmental variables (usually all uppercase characters), used to define the bash working environment
View environment variables: export, declare -x, printenv, env
Undo environment variable: unset name
Read-only variables:
(1) declare -r name
(2) readonly name
Read-only variables can not be reassigned, and does not support the revocation; survival time of the life cycle of the current shell process, and end with the shell process terminates;
bash characteristics as much command:
Using the format: ~] # COMMAND1; COMMAND2; COMMAND3; ...
logic operation:
Operand: true (true, yes, on, 1)
False (false, no, off, 0)
versus:
1 && 1 = 1
1 && 0 = 0
0 && 1 = 0
0 && 0 = 0
or:
1 || 1 = 1
1 || 0 = 1
0 || 1 = 1
0 || 0 = 0
non:
! 1 = 0
! 0 = 1
Short circuit rule:
~]# COMMAND1 && COMMAND2
COMMAND1 as "false", the COMMAND2 will not be executed;
Otherwise, COMMAND1 is "true", the COMMAND2 must perform;
~] # Command1 || Command2
COMMAND1 is "true", the COMMAND2 will not be executed;
Otherwise, COMMAND1 as "false", the COMMAND2 must perform;