Shell variable (V)

What is a variable?
● possible changes in the value of fixed name stored
- to improve the ability to adapt the script for mission requirements, operating environment changes
- to facilitate the execution of the script re-use a value

Definition / variable assignment
● Basic format
- variable name = variable value
● Related Notes
- If the specified variable name already exists, the equivalent of variable value reassignments do this
- no spaces equal on both sides
- variable names from the letter / number / underscore case-sensitive
- variable names can not start with a number, do not use keywords and special characters
Shell variable (V)

Check / reference variable
● basic format
- a reference variable value: $ variable name
- see the value: echo $ variable name, echo $ {variable name}
Shell variable (V)

Cancel variables
● custom variable effectiveness
- when exiting Shell environment variable definition, the variable will automatically expire
- and can also be manually canceled within the context of: unset variable name ...

Classification variable angle
● storage type
- integer, floating point, double precision floating point, character, ...
-Shell not as high-level programming language, the type of storage requirements loose
● usage type
Shell variable (V)

Position variable
● provided command line parameters when executing the script
- represented as $ n, n is a number
- $ 1, $ 2, $ .... {10}, {11} $ ...
Shell variable (V)

● Case
- $ 1 location instead of the user variable
- $ 2 position variable instead of a password
- first position when executing the script represents an increase of users, the second digit represents the user password
Shell variable (V)

Predefined variables
● information is used to execute the program to save the script
- use these variables
- variables can not be assigned directly to the discounted
Shell variable (V)

Guess you like

Origin blog.51cto.com/14449563/2425098