编程能力:脚本编程 编程语言:机器语言、汇编语言、高级语言 静态语言:(编译型)C语言 C++ JAVA C# 动态语言:(边解释边执行) 面向过程:shell C语言 面向对象:JAVA Python perl C++
Shell weakly typed programming language strong: When variables are used, they must be declared in advance, or even initialized weakly: variable time declarations, or even type variable assignments: Var_name=value bash Variable type: environment variable local variable position variable Special variables: $? The execution status return value of the previous command $# parameter number $* parameter list [email protected] parameter list reference variable: ${varname} #括号可省略 e.g A Nimal = Pig echo "There is some ${animal}s." Environment variable: Export VARNAME = VALUE script executes when a child shell process command line inherits the current shell environment variable system Auto-execute script needs to be self-defined For each environment variable location variable: $ "$ $" program execution, there are two types of return values: Program execution results Program status Return code: 0: Correct execution 1-255: Error execution
Syntax: #! /bin/bash #! : Specifies the expression for the test of the magic number condition of the program: [Expression] Command test method [[expression]] keyword testing method Test expression Test command method integer comparison: -eq: (equal) test two integers for equality: for example $a-eq $B-ne: (unequal) test for two integers: unequal to True , equal to False-gt: (greater than) tests whether one number is greater than the other: greater than true, otherwise false -LT: (less than) tests whether one number is less than the other: smaller than true, otherwise false-ge: (greater equal) test two number greater than or equal to -le: (less equal) test two number smaller than or equal to conditional judgment, control structure single branch if statement: if judgment condition; then Statement1. Fi dual-Branch if statement: if judgment condition; then s Tatement1 ... else statement3.. Fi exit: Exit script file Test:-E file: Test files for existence-F file: Test file is normal FILE-D-File: Tests whether the files are directories-r file: The test file is readable- W File: Test whether the file is writable by the-X file: whether the test file can be executed bash-x test script stepping to see if there is a syntax error multi-branch if statement: Judging condition 1;then statement1 ... elif judging condition 2;then Statement2. Elif Judging condition 3;then statement3 .... else Statement3 ... fi
Learning Path (iv): Shell weakly typed programming language and scripting syntax