The Linux Shell Programming (13)

variable:

  

  The rules define the variables:

    1) Variable names can consist of letters, digits, and underscores, but can not start with a number

    2) on both sides of the equal sign can not have spaces

    3) general custom variable name in uppercase

  The return value of the command assigned to a variable:

    

    1) using the command `` quotes

    2) using the $ () to perform

Set the environment variable:

  The basic syntax:

    1) export variable name = variable value output is not the shell variable environment variables

    

    2) source profile allows configuration information after the changes take effect immediately

    

    3) echo $ variable name query environment variables

    

Multiline comments:

  

Location parameter variables:

  When we execute a shell script, if you want to get to the command line parameters, you can use the position parameter variables. As ./myshell.sh 100 200, which is a command-line shell execute, you can get the parameter information myshell script.

  The basic syntax:

    $ N: n is a number, $ 0 for the command itself, $ 1- $ 9 representing the first to ninth parameter, it needs to contain more than ten parameters {10} $ braces

    $ *: On behalf of all the command line parameters

    $ @: On behalf of all the command line parameters, but each parameter will be treated separately

    $ #: The number of all parameters

    

    

Predefined variables: 

  shell designers have designed a pre-defined variables that can be used directly in a shell script. 

  PID of the current process: 1) $$ 

  2) $ !: The last process running in the background process ID 

  3) return to the state $ ?: command last executed. If this variable is 0, demonstrated the correct execution of a command; if the variable is non-zero, then the proof is not correct on a command 

  

  

Guess you like

Origin www.cnblogs.com/az4215/p/11444590.html