The philosophical thought of Linux
All documents
Avoid interaction and implement bash programming
Text Programming Command Implementation configuration
Combine small programs to complete complex tasks
Summarize
Program programming
Interpreting execution
The difference between character and value storage
Shebang, CPU, interpreter
Data type
Variable type, which is the type of the internal data
Bash
Program programming, interpreting execution
The type of the variable is: weak type
ONE) Bash programming
Programming Style: procedural programming, Object-type programming
Program Programming: purpose to solve problems
Only consider how the data is organized
Instruction Organization Data
To complete a complex task
Sequential execution: Running tasks individually
Select Execute: There is a standard to execute only some code snippets
Loop execution: Make some code fragments repeat n times
How the program executes
compile execution: C,java after translation: Advanced language ---------------------------
Explanation execution: Shell,python,java side translation Side Execution , in order to avoid the confusion of the context, the first grammar examination of the program, will be translated: interpreted language---interpreter----Target code
Explain the characteristics of execution
Plain Text , magic number is a code that indicates the path of the interpreter
The source program is executed by the interpreter
The interpreter runs on the CPU , and the text is run by the interpreter
magic number : The source code is compiled into binary, the first n bytes of the file, used to determine the format of the executable program
the structure of the programming language :
data storage: variables, arrays
An expression, a statement
programming languages, in order to make programming simple :
Operating system provides libraries
Provide an interpreter
Shell program:
procedural programming, interpreting execution
Shell Programming Features
Calling System programs directly
Stacking of commands
Environments that rely heavily on the operating system
the format of the shell script :
must have a fixed format: first act magic number
Must be able to read the $path value, bash relies heavily on path to find the execution program file
、
To run the script:
1, give permission, specify the file execution through the specific path
2, direct interpretation of execution, the script as the parameters of the Interpreter program execution
12. Variables
variable name : The memory space of the command that can be referenced by name, and the name of the memory space that can be called beforehand.
Variables: memory space for a single command
program = instruction + data
Data can be stored in variables, arrays, lists, files
The type of data stored in the variable
character type : Use bits to represent all changes. For example, 2^16 represents 5000 variations of all Chinese characters, and this stipulation has gbk2313,gb18030 and so on. 127 variations of all numbers, letters, and special characters with 2^8, ASCII code table specified by the United States
So when storing a Chinese character, use 16 bits, and store a number with 8 bits.
Numeric Type
Integer, numeric data such as 1100 binary conversion to binary number:-----1101110 with 7-bit
Floating point Type
* Any data can be included in these two types of
Today: Characters with 16 + 16 bit
Number of days equivalent to Unix
Boolean type
1:true 0 representation of the status result of a command in bash
1-255 representation of the status result of a command in 0:false bash
Logical operation:
With: The circuit is in series, while the true result is true, the others are false.
Or: The circuit is in parallel, a true result is true, the others are false.
Non: Electromagnetic induction of the circuit, the result of the operation is reversed, non-true is false. Non-false is true
Short-circuit Operation:
With: False on the left and false on the left. True, the second must participate in an operation
or: The first is true and the result is true. False on the left, tenth must participate in the operation
Operation:
All character type: 10 + 110 = 10110
All numeric: 10 + 110 = 120
If the data types in the variables are not uniform, the operation will be confusing
2) variables
Types of variables :
the type of the variable is the type of the data store in the variable
The role of variables:
Deciding which operations to participate in
Determine the data range of the variable: integer 4 bytes, 32 bits, 2^32=40 more than billions of digits
Variable type
Character
Numerical
Integral type
Floating point Type
strongly typed and weakly typed
Strongly typed: Must declare that the variable is a character or numeric type
Weak type : No prior declaration of the type of variable, shell
Characteristics of weak types
Unified storage for Character type
Automatic switching is done if the operation is required
This article from "Reading" blog, declined reprint!
Puff---------Linux Bash Basic features (2)