Bash scripting one variable, variable type
Shell Programming:
Compilers, interpreters
Programming languages: Machine language, assembly language, advanced languages
Static language: Compiled language
Strongly typed (variable) language
convert into executable format in advance
C,C + +,JAVA,C #
Dynamic Language: interpreted language On the fiy
Weak type
Edge interpretation Side Execution
ASP,asp, PHP, Shell,Python,Perl
process oriented:shell,C
Object-oriented: JAVA,Python ,Perl,C + +
Variables: Memory space, naming
Memory: Compiled storage unit
Variable type: Determine the storage format and length of the data in advance
character
value
integral type:
floating point type:
Boolean type: True, False
Logical operations: with, or, not (!) , XOR, or
Shell: weakly typed programming languages
Strongly typed: The variable must be declared beforehand before it is used, and even needs to be initialized;
Empty ( NULL)
Weak type: variable time declaration, not even type;
variable Assignment:
Bash Variable Type:
Environment type:
local variable: (local variable)
positional variables:
Special variables (System variables):
Local variables:
Varname=value : scoped to entire bash process;
Local variables:
Localvarname=valuw : The scope is the current code snippet;
environment variable: scope is current shell process and its child processes
Setexport Varname=value :
"Export"
The script starts a child shell process when it executes ;
scripts that are started on the command line inherit the current shell environment variable
scripts that are automatically executed by the system (not command-line startup) require a self-defined environment variable
Bash :
Positional variables:
$1,$2,...
Special variables:
$?: The execution status return value of the previous command;
There are two possible types of return values for program execution:
Program execution Results
Program Execution status return code (255 )
0 : Execute correctly
(1-255): Error execution,1,2,127 system reserved;
Output redirection:
: Overwrite output
>>: Append output
2>: Redirect Error output
2>>: Append method
&>: simultaneous redirection (redirected error output)
/dev/null: Soft device,bit bucket , data black hole
undo Variable:
Unset VARNAME}
View current shell The variables in:
Set
View current shell Environment Variables in:
Printenv
Env
Export
Script: The stuffing of the command, as the actual need, combined with
shebang : Magic number
# ! /bin/bash
# Comment lines , do not execute
Variable reference:${varname}, parentheses can sometimes be omitted
This article is from the "11913800" blog, please be sure to keep this source http://11923800.blog.51cto.com/11913800/1844530
Linux Learning note--bash scripting one variable, variable type