Shell programming variables and variable types

Source: Internet
Author: User

Programming languages: Including machine language, assembly language, {high-level language [static language (compiled language, generally strongly typed variable, need to be published as executable, C, C + +, java,c#) and dynamic language (interpreted language, generally weakly typed language, not need to be published as an executable program, is one side of the execution side interpretation , asp,asp.net,php,Shell,python, Perl)]}

Object-oriented: solve the action between objects, mainly for the development of large programs Java,python,c++,perl

Process oriented: The main solution process, mainly for the development of small programs shell,c

Variable: is a memory space, is a named memory space, the storage format and length of the stored data, the computer's minimum storage unit is bytes

Memory: Is the addressable storage space

Process: program is called process after running

Logical operations: With, or, non-, XOR (short-circuit logic operations)

True & false = False

False & true = False

False & false = False

True & true = True

and operation when only the two is true, otherwise false, equivalent to the series circuit, as long as there is a false, the result must be false

true | False = True

Fake | True = True

Fake | False = False

true | True = True

Or operation as long as the accesses than either is true, equivalent to the parallel circuit, as long as there is a true, then the result must be true

! true = False

! false = True

is not a single-mesh operation, that is, the inverse operation, equivalent to electromagnetic induction

XOR operand the same number is false, otherwise I really

The compiled language has no additional processing logic so it is strongly typed, and scripting languages can have interpreter control, which can be weakly typed

Strongly typed programming languages: variables must be declared before they are used, or even initialized, and variables that are not initialized are stored in random numbers

Weakly typed programming languages: variables are declared in time, not even distinguished by type, implicit conversions, explicit conversions

Variable assignment: variable = value

Bash Variable type

environment variable, export variable = value, scope is current shell and its child process

Local variables, variable = values, variables must be process variables, scoped to the entire bash process

(local variable), local variable = value, scope is current code snippet

Positional variables, such as back reference references $1,$2 ...

Special variables, bash built-in, also known as system variables, save certain special data, such as $? (Save previous command execution status return value)

Reference variable: ${varname}, sometimes {} number can be omitted

When the script executes, a child shell process is started

Scripts that are started on the command line inherit the current shell environment variable

Scripts that are automatically executed by the system (without the command line) need to define the environment variables required for self-definition

After the program executes, there are generally two return values:

1. Execution result return value

2. Execution status return value

Output redirection

Overwrite redirect

>>: Append redirect

2>: Error redirection

2>> Error Append redirect

&>: Simultaneous (correct, error) redirection


/dev/null, software simulation equipment

/dev/zero


Undo variable: unset variable name

View variables in the current shell: using set, including environment variables and local variables,

To view the environment variables for the current shell: using printenv,env or export

Weakly typed variable types default to character type

GB-2312

This article is from the "ignorance of knowledge" blog, please be sure to keep this source http://yujiqing.blog.51cto.com/1475974/1614930

Shell programming variables and variable types

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.