Two, Shell Script advanced programming combat Part II

First, what is a variable?

        Variable is a constant string replace more complex content, of course, the content of which there may be variable, path, string and much more, the biggest feature is easy to use, better work

      1. Environment variables variable (global variable) and local variables

       Environment variable is a global variable, you can create can be used in their shell and spawn a shell

       Local variables can only be used in the creation of their shell.  

 Personally I think that this is not very serious, because as the article mentioned before, if you define a local variable in a script, for example:. Source xx.sh or (points) xx.sh it? The same can invoke the script variables.

Second, the environment variable

        Shell environment variables used to define the operating environment, ensure the correct execution of shell commands. All the environmental variables are global, casual script, because the script is executed first execution environment variable is loaded again; .bash_profile file in the global configuration or / etc / profile In general, / etc / bashrc file or / etc /profile.d in the definition. The environment variable into the profile, each time a user logs on it initialized.

        Traditionally, environment variables are capitalized. By command env, set for viewing system-defined number of environmental variables.

        Each user typically has the following documents .bashrc and .bash_profile; global environment is under / etc / profile and file / etc / bashrc, / etc / profile.d; special note is, / etc / motd is generally below login string displayed

  Third, local variables

       Just take effect in the current shell.

    Whether it is a local variable or a global variable, by default, numbers do not add quotation marks, the other with double quotation marks.

 

Guess you like

Origin www.cnblogs.com/dangjingwei/p/11594952.html
Recommended