On the third day of school shell

Programming principle:
1. Introduction to Programming
   early programming
      drive hardware default can not be used;
        the need for command communication between different hardware device manufacturers, we need drivers to be translated;
        more close and hardware development engineers, to learn "compilation language "; and" assembly language "is limited to manufacturers
   now programming
      based on high-level language, as well as ultra-high-level language, better enable programmers to achieve programming
   classification of programming languages:
      high-level language, ultra-high-level language to be translated into computer-readable language (binary instructions)
      interpreted - translation row line execution shell
      compiled - once compiled, all of the implementation language c ++ c # c
      program instructions = + data
      Object-oriented - focusing on the data programming language
      for the process - focusing on the instruction
   programming language implementation:
      1, the order of execution
      2, loop execution --FOR (traverse) while (loop condition) an until (and while the opposite)
      3, choose to perform - Case branch * * IF
2, the shell script languages introduction
   advantages: call the command os (operating system) of the line to achieve all functions;
   disadvantages: no library calls
   a shell script This includes: 1, the command * * (very important) 2, variable (global variables, local variables, local variables, parameter passing) 3, logic
   shell first words! ! !
   ! # / bin / bash - defined script interpreter
   / etc / shells --- see the current system to support the shell program
   echo $ SHELL - view the current session of the shell program
   / etc / passwd - developed a user supported by default shell program
   shell execution:
      1.bash command to execute the script
         -n see a shell script logic error (Note: the word wrong can be whatever)
         -x progressive script execution (easy troubleshooting)
      2. Authorizes chmod u + filename.sh X
. 3, variable
   environment variables
   local variables declare command - define variable type
   local variable used in the function local
   variable types:
      numeric:
         1. plastic
         2. float
         3 0 1 Boolean (true or false) ( true False)
    string:
       1. Common character strings and
       2. array
    classification of programming languages:
       a strongly typed language: - the value must be defined in order to carry out the processing operation or
       a weakly typed language: - programming language may automatically identify the type of variable
     * * [Polymorphic data having a plurality of attributes, the properties depend on the final use of the data and its operation]
    mass parameter
       $ -? A command execution status 0 1-255 correct errors
       $ 1 $ 2 $ 3 $ 10 { } - incoming data script command back to space as a delimiter
       $ # - the amount of statistical parameters passed $ {$ #} this is the last parameter passing
       $ * - indicates all parameter passing, pass all parameters to characters string form of output
       $ @ - represents all the mass participation, all the mass participation in the form of a list of output
    formats defined variables:
        NAME = of VALUE
        I did not let you define the variable type the command declare
        declare -i integer
        declare -a array
    variable naming:
       1. underlined specify variable names
       2. hump nomenclature
4, test file test, to determine the conditions
   in the script, we need to make the statement branch; it plainly, they do judge
   judge is to use the test command to achieve
   using the format :

    1.test parameter file

    2.[条件语句]
   常见的test选项:
      比较选项:
      -eq等于
      -ne不等于
      -gt 大于
      -ge大于等于
      -lt小于
      -le小于等于
    文件判断选项:
      -f     -d    -L       -r       -w        -x
    关联选项:
      -o 或
      -a 与
      ! 非
    字符串判断
       =
       !=
       -z 判断字符串长度是否为0
       -n和z相反
5、逻辑运算
   与 &&:两边的命令,都是真,结果才是真
   或 ||:两边的命令,一边为真就是真,同时为假才为假
   非        !=
6、算数运算
   let   加法
   expr 乘法
   $[$1+10]
   $(($1/$2))
   + - * / % **

Guess you like

Origin www.cnblogs.com/zrxuexi/p/11347458.html